-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathprototype.ats
55 lines (33 loc) · 851 Bytes
/
prototype.ats
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Logger } from '../logger';
import { int, float } from '../lang';
export class Prototype {
constructor(){
}
doClone():Prototype {
throw new Error("Abstract method!");
}
}
export class Person extends Prototype {
constructor(surname:string) {
this.logger = new Logger();
this.surname = surname;
}
doClone():Prototype {
return new Person(this.surname);
}
toString():string{
return this.logger.log("This person is named " + this.surname);
}
}
export class Dog extends Prototype {
constructor(sound:string) {
this.logger = new Logger();
this.sound = sound;
}
doClone():Prototype {
return new Dog(this.sound);
}
toString():string {
return this.logger.log("This dog says " + this.sound);
}
}