-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
41 lines (33 loc) · 1.01 KB
/
Main.java
File metadata and controls
41 lines (33 loc) · 1.01 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
public class Main {
public static void main(String[] args) {
System.out.println("Beginning Animal demo with movement strategies:");
// Expected bahviours
Animal dog = new Dog(new Walk());
dog.traverse();
dog.speak();
System.out.println("");
Animal tadpole = new Tadpole(new Swim());
tadpole.traverse();
tadpole.speak();
System.out.println("");
Animal hawk = new Hawk(new Fly());
hawk.traverse();
hawk.speak();
System.out.println("");
System.out.println("Decorating animals:");
// Dog is flying???
dog = new AddFlight(dog);
dog.traverse();
dog.speak();
System.out.println("");
// Tadpole is walking???
tadpole = new AddWalking(tadpole);
tadpole.traverse();
tadpole.speak();
System.out.println("");
// Hawk is swimming???
hawk = new AddSwimming(hawk);
hawk.traverse();
hawk.speak();
}
}