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
🌞 Morning 25 commits ▊░░░░░░░░░░░░░░░░░░░░ 3.9% | |
🌆 Daytime 201 commits ██████▋░░░░░░░░░░░░░░ 31.7% | |
🌃 Evening 328 commits ██████████▊░░░░░░░░░░ 51.7% | |
🌙 Night 81 commits ██▋░░░░░░░░░░░░░░░░░░ 12.8% |
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
let myCoffee = new Americano(); | |
console.log(`${myCoffee.getDescription()}는 ${myCoffee.cost()}원입니다~`); | |
let myCoffee2 = new CaffeeLatte(); | |
myCoffee2 = new Ice(myCoffee2); | |
myCoffee2 = new Whip(myCoffee2); | |
myCoffee2 = new Whip(myCoffee2); | |
console.log(`${myCoffee2.getDescription()}는 ${myCoffee2.cost()}원입니다~`); |
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
class Whip extends BeverageDecorator { | |
private beverage: Beverage; | |
constructor(beverage: Beverage) { | |
super(); | |
this.beverage = beverage; | |
} | |
getDescription() { | |
return this.beverage.getDescription() + ", 휘핑"; | |
} | |
cost() { |
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
class CaffeeLatte extends Beverage { | |
constructor() { | |
super(); | |
this.description = "카페라떼"; | |
} | |
cost() { | |
return 4500; | |
} | |
} |
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
let myCoffee = new Americano(); | |
myCoffee = new Ice(myCoffee); | |
console.log(`${myCoffee.getDescription()}는 ${myCoffee.cost()}원입니다~`); | |
let myCoffee2 = new Americano(); | |
myCoffee2 = new Ice(myCoffee2); | |
myCoffee2 = new Ice(myCoffee2); | |
console.log(`${myCoffee2.getDescription()}는 ${myCoffee2.cost()}원입니다~`); |
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
class Ice extends BeverageDecorator { | |
private beverage: Beverage; | |
constructor(beverage: Beverage) { | |
super(); | |
this.beverage = beverage; | |
} | |
getDescription() { | |
return this.beverage.getDescription() + ", 아이스"; | |
} |
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 BeverageDecorator extends Beverage { | |
abstract getDescription(): string; | |
} |
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
class Americano extends Beverage { | |
constructor() { | |
super(); | |
this.description = "아메리카노"; | |
} | |
cost() { | |
return 3000; | |
} | |
} |
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; | |
public getDescription(): string { | |
return this.description; | |
} | |
abstract cost(): number; | |
} |
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; | |
} |
NewerOlder