package Chap_07;
class Hambuger {
// ์ธ์คํด์ค ๋ณ์
public String name;
public String ingredient1;
public String ingredient2;
public String ingredient3;
// ์์ฑ์
public Hambuger(){
this("ํ๋ฒ๊ฑฐ");
}
public Hambuger(String name){
this.name = name;
this.ingredient1 = "์์์ถ";
this.ingredient2 = "ํจํฐ";
this.ingredient3 = "ํผํด";
}
// ๋งค์๋
public void cook() {
System.out.println(name + "๋ฅผ ๋ง๋ญ๋๋ค.");
System.out.println("๋นต ์ฌ์ด์ ๋ค์ด๊ฐ๋ ์ฌ๋ฃ๋?");
System.out.println("> " + ingredient1 +"\n+ " + ingredient2 +"\n+ " + ingredient3);
}
}
class CheeseBurger extends Hambuger {
//๋ณ์
public String ingredient4;
//์์ฑ์
public CheeseBurger() {
super("์น์ฆ๋ฒ๊ฑฐ");
this.ingredient4 = "์น์ฆ";
}
// ๋งค์๋
public void cook() {
super.cook();
System.out.println("+ " + ingredient4);
}
}
class ShrimpBurger extends Hambuger {
// ๋ณ์
public String ingredient5;
// ์์ฑ์
public ShrimpBurger() {
super();
this.name = "์์ฐ๋ฒ๊ฑฐ";
this.ingredient5 = "์์ฐ";
}
// ๋งค์๋
public void cook() {
super.cook();
System.out.println("+ " + ingredient5);
}
}
public class _Quiz_07 {
public static void main(String[] args) {
Hambuger[] hambugers = new Hambuger[3];
hambugers[0] = new Hambuger();
hambugers[1] = new CheeseBurger();
hambugers[2] = new ShrimpBurger();
System.out.println("์ฃผ๋ฌธํ์ ๋ฉ๋ด๋ฅผ ๋ง๋ญ๋๋ค.");
System.out.println("---------------------");
for (Hambuger hamburger :
hambugers) {
hamburger.cook();
System.out.println("-----------------------");
}
System.out.println("๋ฉ๋ด ์ค๋น๊ฐ ์๋ฃ๋์์ต๋๋ค.");
}
}
0