-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...c/main/java/week3/poly/diamond/Child.java → ...in/java/week3/poly/ex5/diamond/Child.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../java/week3/poly/diamond/DiamondMain.java → ...a/week3/poly/ex5/diamond/DiamondMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/java/week3/poly/diamond/InterfaceA.java → ...va/week3/poly/ex5/diamond/InterfaceA.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package week3.poly.diamond; | ||
package week3.poly.ex5.diamond; | ||
|
||
public interface InterfaceA { | ||
void methodA(); | ||
|
2 changes: 1 addition & 1 deletion
2
...n/java/week3/poly/diamond/InterfaceB.java → ...va/week3/poly/ex5/diamond/InterfaceB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package week3.poly.diamond; | ||
package week3.poly.ex5.diamond; | ||
|
||
public interface InterfaceB { | ||
void methodB(); | ||
|
9 changes: 9 additions & 0 deletions
9
임준형/java-basic/src/main/java/week3/poly/ex6/AbstractAnimal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package week3.poly.ex6; | ||
|
||
public abstract class AbstractAnimal { | ||
public abstract void sound(); | ||
|
||
public void move() { | ||
System.out.println("동물이 이동합니다."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package week3.poly.ex6; | ||
|
||
public class Bird extends AbstractAnimal implements Fly { | ||
@Override // AbstractAnimal | ||
public void sound() { | ||
System.out.println("짹짹"); | ||
} | ||
|
||
@Override | ||
public void fly() { | ||
System.out.println("새 날기"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package week3.poly.ex6; | ||
|
||
public class Chicken extends AbstractAnimal implements Fly { | ||
@Override | ||
public void sound() { | ||
System.out.println("꼬기오"); | ||
} | ||
|
||
@Override | ||
public void fly() { | ||
System.out.println("닭 날기"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package week3.poly.ex6; | ||
|
||
public class Dog extends AbstractAnimal { | ||
@Override | ||
public void sound() { | ||
System.out.println("멍멍"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package week3.poly.ex6; | ||
|
||
public interface Fly { | ||
void fly(); | ||
} |
32 changes: 32 additions & 0 deletions
32
임준형/java-basic/src/main/java/week3/poly/ex6/SoundFlyMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package week3.poly.ex6; | ||
|
||
public class SoundFlyMain { | ||
|
||
public static void main(String[] args) { | ||
Dog dog = new Dog(); | ||
Bird bird = new Bird(); | ||
Chicken chicken = new Chicken(); | ||
|
||
soundAnimal(dog); | ||
soundAnimal(bird); | ||
soundAnimal(chicken); | ||
|
||
flyAnimal(bird); | ||
flyAnimal(chicken); | ||
} | ||
|
||
//AbstractAnimal 사용 가능 | ||
private static void soundAnimal(AbstractAnimal animal) { | ||
System.out.println("동물 소리 테스트 시작"); | ||
animal.sound(); | ||
System.out.println("동물 소리 테스트 종료"); | ||
} | ||
|
||
//Fly 인터페이스가 있으면 사용 가능 | ||
private static void flyAnimal(Fly fly) { | ||
System.out.println("날기 테스트 시작"); | ||
fly.fly(); | ||
System.out.println("날기 테스트 종료"); | ||
} | ||
|
||
} |