package ex02๋ํ
๋๊ฒ์๊ธฐ;
public class Dongmul extends GameChip {
@Override
public void start() {
System.out.println("๋๋ฌผ์์ฒ ๊ฒ์์ ์์ํฉ๋๋ค.");
}
}
package ex02๋ํ
๋๊ฒ์๊ธฐ;
public class Mario extends GameChip {
@Override
public void start() {
System.out.println("๋ง๋ฆฌ์ค์นดํธ ๊ฒ์์ ์์ํฉ๋๋ค.");
}
}
package ex02๋ํ
๋๊ฒ์๊ธฐ;
public class Zelda extends GameChip {
@Override
public void start() {
System.out.println("์ ค๋ค์ ์ ์ค์ ์์ํฉ๋๋ค.");
}
}
package ex02๋ํ
๋๊ฒ์๊ธฐ;
public class Poke extends GameChip {
// start ๋ฉ์๋ ์ฌ์ ์ํ๊ธฐ
public void start() {
System.out.println("ํฌ์ผ๋ชฌ๊ฒ์์ ์์ํฉ๋๋ค.");
}
}
package ex02๋ํ
๋๊ฒ์๊ธฐ;
public class Main {
// ์คํํ๋ ๊ณต๊ฐ, ๋ํ
๋ ๊ฒ์๊ธฐ
public static void main(String[] args) {
Mario ma = new Mario();
playGame(ma);
Dongmul dong = new Dongmul();
playGame(dong);
Zelda zel = new Zelda();
playGame(zel);
// Gamechip ma = new Zelda();
}
private static void playGame(GameChip ma) {
ma.start();
// ๊ฒ์ ์คํ์ํค๊ธฐ
}
// ๋ฉ์๋ ์ค๋ฒ๋ก๋ฉ ๋ฐฉ์์ผ๋ก ๋ฌธ์ ํด๊ฒฐ ๋ฐฉ๋ฒ
// --> ๊ฒ์์นฉ์ ์ถ๊ฐํ ๋๋ง๋ค ๋ฉ์๋๋ฅผ ํ๋์ฉ ๋ค์ ์์ฑ
// private static void playGame(Dongmul dong) {
// dong.start();
// }
// private static void playGame(Mario ma) {
// ma.start();
// }
// private static void playGame(Zelda zel) {
// zel.start();
// }
}