상속 합성
package ex05.composit;
public class Burger {
private int price;
private String desc;
public Burger() {
this(1000, "버거");
}
public Burger(int price) {
this(price, "버거");
}
public Burger(int price, String desc) {
this.price = price;
this.desc = desc;
System.out.println("버거가 만들어졌습니다");
}
public int getPrice() {
return price;
}
public String getDesc() {
return desc;
}
}
package ex05.composit;
public class BigBurger extends Burger {
public BigBurger() {
super(1500, "빅버거");
System.out.println("빅버거가 만들어졌습니다");
}
public BigBurger(int price, String desc) {
super(price, desc);
System.out.println("빅버거가 만들어졌습니다");
}
}
package ex05.composit;
public class ExApp01 {
public static void main(String[] args) {
Burger b1 = new Burger();
System.out.println("==============");
Burger b2 = new Burger(800, "버거");
System.out.println("==============");
Burger b3 = new Burger(500);
System.out.println("==============");
BigBurger bb1 = new BigBurger();
System.out.println("==============");
BigBurger bb2 = new BigBurger(1300, "빅버거");
System.out.println("==============");
}
}