-
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
5 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
임준형/java-basic/src/main/java/week3/poly/ex4/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,7 @@ | ||
package week3.poly.ex4; | ||
|
||
public abstract class AbstractAnimal { | ||
|
||
public abstract void sound(); | ||
public abstract void move(); | ||
} |
32 changes: 32 additions & 0 deletions
32
임준형/java-basic/src/main/java/week3/poly/ex4/AbstractMain.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.ex4; | ||
|
||
public class AbstractMain { | ||
|
||
public static void main(String[] args) { | ||
Dog dog = new Dog(); | ||
Cat cat = new Cat(); | ||
Caw caw = new Caw(); | ||
|
||
cat.sound(); | ||
cat.move(); | ||
|
||
soundAnimal(dog); | ||
moveAnimal(dog); | ||
|
||
soundAnimal(cat); | ||
moveAnimal(cat); | ||
|
||
soundAnimal(caw); | ||
moveAnimal(caw); | ||
} | ||
|
||
private static void soundAnimal(AbstractAnimal animal) { | ||
System.out.println("테스트 시작"); | ||
animal.sound(); | ||
System.out.println("테스트 종료"); | ||
} | ||
|
||
private static void moveAnimal(AbstractAnimal animal) { | ||
animal.move(); | ||
} | ||
} |
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,14 @@ | ||
package week3.poly.ex4; | ||
|
||
public class Cat extends AbstractAnimal { | ||
|
||
@Override | ||
public void sound() { | ||
System.out.println("야옹"); | ||
} | ||
|
||
@Override | ||
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,14 @@ | ||
package week3.poly.ex4; | ||
|
||
|
||
public class Caw extends AbstractAnimal { | ||
@Override | ||
public void sound() { | ||
System.out.println("음메"); | ||
} | ||
|
||
@Override | ||
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,14 @@ | ||
package week3.poly.ex4; | ||
|
||
|
||
public class Dog extends AbstractAnimal { | ||
@Override | ||
public void sound() { | ||
System.out.println("멍멍"); | ||
} | ||
|
||
@Override | ||
public void move() { | ||
System.out.println("개 이동"); | ||
} | ||
} |