forked from michikono/typescript-tdd-exercises
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcar.ts
30 lines (25 loc) · 725 Bytes
/
car.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
/// <reference path="../../../references.ts" />
module Example {
export module MechanicalThings {
export class CarImpl implements Transportation {
private x:number = 0;
private y:number = 0;
sound():string {
return "vroom!";
}
position():Coordinate {
return {
x: this.x,
y: this.y
};
}
velocity() {
return 1;
}
move(offset:Coordinate) {
this.x = this.x + (offset.x * this.velocity());
this.y = this.y + (offset.y * this.velocity());
}
}
}
}