forked from michikono/typescript-tdd-exercises
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdriver.ts
34 lines (24 loc) · 747 Bytes
/
driver.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/// <reference path="../../references.ts" />
module Example {
export class Driver {
private coordinate:Coordinate = {x: 0, y: 0};
constructor(private vehicle:MechanicalThings.Transportation) {
}
park() {
var position = this.vehicle.position();
this.vehicle.move({x: -position.x / this.vehicle.velocity(), y: -position.y / this.vehicle.velocity()});
}
goForward() {
this.vehicle.move({x: 0, y: 1});
}
goBackwards() {
this.vehicle.move({x: 0, y: -1});
}
turnLeft() {
this.vehicle.move({x: -1, y: 0});
}
turnRight() {
this.vehicle.move({x: 1, y: 0});
}
}
}