-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlaundry.ts
More file actions
50 lines (39 loc) · 1.17 KB
/
laundry.ts
File metadata and controls
50 lines (39 loc) · 1.17 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
class Laundry {
color :string;
type: string;
folds: number;
}
class LaundryFolder {
constructor(){
}
public GrabFromBasket(laundry : Laundry) : FoldingCommand{
laundry.folds = 0;
return new FoldingCommand(laundry);
}
}
class FoldingCommand{
laundry : Laundry;
constructor(laundry : Laundry){
this.laundry = laundry;
}
public FoldGood() : FoldingCommand{
this.laundry.folds++;
return this;
}
public FoldRealGood() : FoldingCommand{
this.laundry.folds++;
return this;
}
public CrapIDroppedIt() : FoldingCommand{
this.laundry.folds = 0;
return this;
}
public PlaceInCloset() : void{
console.log("Placed the " + this.laundry.color + " " + this.laundry.type + " in the closet!");
}
}
var clothingItem = new Laundry();
clothingItem.color = "blue";
clothingItem.type = "shirt";
new LaundryFolder().GrabFromBasket(clothingItem).FoldGood().CrapIDroppedIt().CrapIDroppedIt().PlaceInCloset();
new LaundryFolder().GrabFromBasket(clothingItem).FoldGood().FoldRealGood().FoldGood().CrapIDroppedIt().PlaceInCloset();