From 5e380a02dd326ec7733840add93b5b5e269870e3 Mon Sep 17 00:00:00 2001 From: toychip Date: Wed, 14 Feb 2024 00:02:39 +0900 Subject: [PATCH] =?UTF-8?q?[Week3][Chap11]=20=EC=B6=94=EC=83=81=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A41=20(#26)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/week3/poly/ex3/AbstractAnimal.java" | 9 ++++++++ .../java/week3/poly/ex3/AbstractMain.java" | 23 +++++++++++++++++++ .../src/main/java/week3/poly/ex3/Cat.java" | 9 ++++++++ .../src/main/java/week3/poly/ex3/Caw.java" | 9 ++++++++ .../src/main/java/week3/poly/ex3/Dog.java" | 9 ++++++++ 5 files changed, 59 insertions(+) create mode 100644 "\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/AbstractAnimal.java" create mode 100644 "\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/AbstractMain.java" create mode 100644 "\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Cat.java" create mode 100644 "\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Caw.java" create mode 100644 "\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Dog.java" diff --git "a/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/AbstractAnimal.java" "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/AbstractAnimal.java" new file mode 100644 index 0000000..ed05fa6 --- /dev/null +++ "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/AbstractAnimal.java" @@ -0,0 +1,9 @@ +package week3.poly.ex3; + +public abstract class AbstractAnimal { + + public abstract void sound(); + public void move(){ + System.out.println("동물이 움직입니다."); + } +} diff --git "a/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/AbstractMain.java" "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/AbstractMain.java" new file mode 100644 index 0000000..22fae96 --- /dev/null +++ "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/AbstractMain.java" @@ -0,0 +1,23 @@ +package week3.poly.ex3; + +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); + soundAnimal(cat); + soundAnimal(caw); + } + + private static void soundAnimal(AbstractAnimal animal) { + System.out.println("테스트 시작"); + animal.sound(); + System.out.println("테스트 종료"); + } +} diff --git "a/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Cat.java" "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Cat.java" new file mode 100644 index 0000000..38a1b8b --- /dev/null +++ "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Cat.java" @@ -0,0 +1,9 @@ +package week3.poly.ex3; + +public class Cat extends AbstractAnimal { + + @Override + public void sound() { + System.out.println("야옹"); + } +} diff --git "a/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Caw.java" "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Caw.java" new file mode 100644 index 0000000..a705eb6 --- /dev/null +++ "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Caw.java" @@ -0,0 +1,9 @@ +package week3.poly.ex3; + + +public class Caw extends AbstractAnimal { + @Override + public void sound() { + System.out.println("음메"); + } +} diff --git "a/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Dog.java" "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Dog.java" new file mode 100644 index 0000000..a3daa2c --- /dev/null +++ "b/\354\236\204\354\244\200\355\230\225/java-basic/src/main/java/week3/poly/ex3/Dog.java" @@ -0,0 +1,9 @@ +package week3.poly.ex3; + + +public class Dog extends AbstractAnimal { + @Override + public void sound() { + System.out.println("멍멍"); + } +}