-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathautobot.js
More file actions
57 lines (57 loc) · 1.53 KB
/
autobot.js
File metadata and controls
57 lines (57 loc) · 1.53 KB
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
55
56
57
var Autobot = (function () {
function Autobot() {
this.name = "";
this.make = "";
this.model = "";
}
Autobot.prototype.HasNameOf = function (name) {
this.name = name;
return this;
};
Autobot.prototype.WithMake = function (make) {
this.make = make;
return this;
};
Autobot.prototype.AndModel = function (model) {
this.model = model;
return this;
};
Autobot.prototype.TransformToAuto = function () {
return new AutoModeCommand(this);
};
return Autobot;
}());
var AutoModeCommand = (function () {
function AutoModeCommand(bot) {
this.autobot = bot;
}
AutoModeCommand.prototype.Speak = function (phrase) {
console.log(phrase);
return this;
};
AutoModeCommand.prototype.Drive = function () {
console.log(this.autobot.name + " begins to drive.");
return this;
};
AutoModeCommand.prototype.TransformToBot = function () {
return new BotModeCommand(this.autobot);
};
return AutoModeCommand;
}());
var BotModeCommand = (function () {
function BotModeCommand(bot) {
this.autobot = bot;
}
BotModeCommand.prototype.Shoot = function () {
return this;
};
BotModeCommand.prototype.Speak = function (phrase) {
console.log(phrase);
return this;
};
BotModeCommand.prototype.TransformToAuto = function () {
return new AutoModeCommand(this.autobot);
};
return BotModeCommand;
}());
var bot = new Autobot();