Skip to content

Instantly share code, notes, and snippets.

@gyugyu90
Last active October 12, 2024 08:18
Show Gist options
  • Save gyugyu90/8f7faaca34aa1152c992b896f5d8a06a to your computer and use it in GitHub Desktop.
Save gyugyu90/8f7faaca34aa1152c992b896f5d8a06a to your computer and use it in GitHub Desktop.
class Coffee {
String beanType;
int waterAmount;
bool hot;
Syrup? syrup;
Coffee(this.beanType, [this.waterAmount = 40, this.hot = true, this.syrup]);
Coffee.iceAmericano(this.beanType, this.waterAmount, [this.syrup])
: hot = false;
Coffee.sweetIceAmericano(String beanType)
: this(beanType, 200, false, Syrup('Sugar', 5)); // redirect
bool isEspresso() {
return waterAmount <= 50;
}
}
void main() {
var coffee = Coffee.sweetIceAmericano('콜롬비아 수프리모');
print(coffee.syrup?.amount); // 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment