-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoundFlyMain.java
More file actions
43 lines (37 loc) · 1.24 KB
/
Copy pathSoundFlyMain.java
File metadata and controls
43 lines (37 loc) · 1.24 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
package poly.ex6;
public class SoundFlyMain {
public static void main(String[] args) {
Dog dog = new Dog();
Bird bird = new Bird();
Chicken chicken = new Chicken();
animalSound(dog);
animalSound(bird);
animalSound(chicken);
moveAnimal(dog);
moveAnimal(bird);
moveAnimal(chicken);
//flyAnimal(dog); fly 상속 받지 않음
flyAnimal(bird);
flyAnimal(chicken);
}
//AbstractAnimal 사용 가능
private static void animalSound(AbstractAnimal animal) {
System.out.println("동물 소리 테스트 시작");
animal.sound();
System.out.println("동물 소리 테스트 종료");
System.out.println();
}
private static void moveAnimal(AbstractAnimal animal) {
System.out.println("동물 이동 테스트 시작");
animal.move();
System.out.println("동물 이동 테스트 종료");
System.out.println();
}
//Fly 인터페이스가 있으면 가용 가능
private static void flyAnimal(Fly fly) {
System.out.println("날기테스트 시작");
fly.fly();
System.out.println("날기 이동 테스트 종료");
System.out.println();
}
}