Created
July 11, 2020 16:09
-
-
Save korECM/b1c97c5d52e321c372f19320b4f62fa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Beverage { | |
protected description: string; | |
private ice: boolean; // 얼름 | |
private mocha: boolean; // 모카 | |
private whip: boolean; // 휘핑 | |
getDescription(): string { | |
return this.description; | |
} | |
protected setIce() { | |
this.ice = true; | |
} | |
protected hasIce() { | |
return this.ice; | |
} | |
protected setMocha() { | |
this.mocha = true; | |
} | |
protected hasMocha() { | |
return this.mocha; | |
} | |
protected setWhip() { | |
this.whip = true; | |
} | |
protected hasWhip() { | |
return this.whip; | |
} | |
abstract cost(): number; | |
} | |
class Americano extends Beverage { | |
constructor() { | |
super(); | |
this.description = "아메리카노~"; | |
} | |
cost() { | |
let baseCost = 4000; | |
if (this.hasIce()) baseCost += 500; | |
if (this.hasMocha()) baseCost += 1000; | |
if (this.hasWhip()) baseCost += 300; | |
return baseCost; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment