Commit 0125c1c1 authored by Stefanie Hasler's avatar Stefanie Hasler

tcr

parent db154d89
......@@ -3,16 +3,21 @@ import {expect} from 'chai'
class MarsRover {
x: number = 0
y: number = 0
dir: 'N' = 'N'
dir: 'N' | 'E' = 'N'
public pos() {
return `${this.x},${this.y},${this.dir}`
}
north() {
north(): MarsRover {
this.y++
return this
}
right(): MarsRover {
this.dir = 'E'
return this
}
}
describe("MarsRover", () => {
......@@ -23,4 +28,8 @@ describe("MarsRover", () => {
it('should move north', () => {
expect(new MarsRover().north().pos()).to.equal('0,1,N')
})
it('should turn right', () => {
expect(new MarsRover().right().pos()).to.equal('0,0,E')
})
})
\ 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