Commit 897e7f34 authored by Stefanie Hasler's avatar Stefanie Hasler

tcr

parent 0125c1c1
......@@ -3,7 +3,7 @@ import {expect} from 'chai'
class MarsRover {
x: number = 0
y: number = 0
dir: 'N' | 'E' = 'N'
dir: 'N' | 'E' | 'S' = 'N'
public pos() {
return `${this.x},${this.y},${this.dir}`
......@@ -15,7 +15,12 @@ class MarsRover {
}
right(): MarsRover {
this.dir = 'E'
switch(this.dir) {
case 'N': this.dir = 'E'
break
case 'E': this.dir = 'S'
break
}
return this
}
}
......@@ -32,4 +37,8 @@ describe("MarsRover", () => {
it('should turn right', () => {
expect(new MarsRover().right().pos()).to.equal('0,0,E')
})
it('should turn right twice in a row, then point south', () => {
expect(new MarsRover().right().right().pos()).to.equal('0,0,S')
})
})
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment