πŸ“ ex01

β˜• YalcoChicken.java

public class YalcoChicken {
    protected int no;
    protected String name;

    public YalcoChicken (int no, String name) {
        this.no = no;
        this.name = name;
    }

    public void takeHallOrder () {
        System.out.printf("%d호 %s점 홀 μ£Όλ¬Έ λ°›μŒ%n", no, name);
    }
}

λ“œλΌμ΄λΈŒμŠ€λ£¨λ₯Ό κ°–μΆ˜ μ–„μ½”μΉ˜ν‚¨μ˜ 클래슀λ₯Ό λ§Œλ“ λ‹€λ©΄?

β˜• YalcoChickenDT.java

public class YalcoChickenDT extends YalcoChicken {
    private boolean driveThruOpen = true;

    public YalcoChickenDT(int no, String name) {
        super(no, name); // λ‹€μŒ μ˜ˆμ œμ—μ„œ λ‹€λ£° 것
    }

    public void setDriveThruOpen(boolean driveThruOpen) {
        this.driveThruOpen = driveThruOpen;
    }

    public void takeDTOrder () {
        System.out.printf(
                "%d호 %s점 λ“œλΌμ΄λΈŒμŠ€λ£¨ μ£Όλ¬Έ %s%n",
                no, name,
                (driveThruOpen ? "λ°›μŒ" : "λΆˆκ°€")
        );
    }
}

β˜• Main.java

				YalcoChickenDT dtStore1 = new YalcoChickenDT(108, "철원");

        dtStore1.takeHallOrder();

        dtStore1.takeDTOrder();
        dtStore1.setDriveThruOpen(false);
        dtStore1.takeDTOrder();

λ©”μ†Œλ“œ μ˜€λ²„λΌμ΄λ”©