Commit 2f75fc9e authored by Stefanie Hasler's avatar Stefanie Hasler

tcr

parent 897e7f34
......@@ -3,7 +3,7 @@ import {expect} from 'chai'
class MarsRover {
x: number = 0
y: number = 0
dir: 'N' | 'E' | 'S' = 'N'
dir: 'N' | 'E' | 'S' | 'W' = 'N'
public pos() {
return `${this.x},${this.y},${this.dir}`
......@@ -20,6 +20,7 @@ class MarsRover {
break
case 'E': this.dir = 'S'
break
case 'S': this.dir = 'W'
}
return this
}
......@@ -41,4 +42,9 @@ describe("MarsRover", () => {
it('should turn right twice in a row, then point south', () => {
expect(new MarsRover().right().right().pos()).to.equal('0,0,S')
})
it('should turn right three times, then point west', () => {
expect(new MarsRover().right().right().right().pos()).to.equal('0,0,W')
})
})
\ 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