Last active
August 26, 2021 13:07
-
-
Save doyle-flutter/6f19f10bdd74baf2e3d872bdbf796345 to your computer and use it in GitHub Desktop.
부대찌개, 김치찌개 ...
This file contains hidden or 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
| void main() { | |
| Future(() async{ | |
| await Jjigae( | |
| name: "🍲 부대찌개", | |
| water: FoodIngredient(productName: "사골", gramme: "500g"), | |
| vegetables: [ | |
| FoodIngredient(productName: "양파", gramme: "30g"), | |
| FoodIngredient(productName: "대파", gramme: "30g"), | |
| ], | |
| spices: [ | |
| FoodIngredient(productName: "소금", gramme: "10g"), | |
| FoodIngredient(productName: "후추", gramme: "2g"), | |
| FoodIngredient(productName: "고춧가루", gramme: "10g"), | |
| FoodIngredient(productName: "고추장", gramme: "20g"), | |
| FoodIngredient(productName: "된장", gramme: "5g"), | |
| ], | |
| meats: [ | |
| FoodIngredient(productName: "돼지고기_목살", gramme: "100g"), | |
| FoodIngredient(productName: "스팸", gramme: "100g"), | |
| FoodIngredient(productName: "소세지", gramme: "100g"), | |
| ] | |
| ).serve(); | |
| await Jjigae( | |
| name: "🍲 김치찌개", | |
| water: FoodIngredient(productName: "사골", gramme: "500g"), | |
| vegetables: [ | |
| FoodIngredient(productName: "양파", gramme: "30g"), | |
| FoodIngredient(productName: "대파", gramme: "30g"), | |
| FoodIngredient(productName: "쉰김치", gramme: "100g"), | |
| ], | |
| spices: [ | |
| FoodIngredient(productName: "소금", gramme: "10g"), | |
| FoodIngredient(productName: "후추", gramme: "2g"), | |
| FoodIngredient(productName: "고추장", gramme: "20g"), | |
| ], | |
| meats: [ | |
| FoodIngredient(productName: "돼지고기_목살", gramme: "100g"), | |
| ] | |
| ).serve(); | |
| }); | |
| } | |
| class FoodIngredient{ | |
| String productName; | |
| String gramme; | |
| FoodIngredient({required this.productName,required this.gramme}); | |
| } | |
| class BudaeJjigae{ | |
| bool isCooking = false; | |
| final FoodIngredient water; | |
| final FoodIngredient ham; | |
| final FoodIngredient sausage; | |
| final List<FoodIngredient> spices; | |
| final List<FoodIngredient> vegetables; | |
| BudaeJjigae({ | |
| required this.water, | |
| required this.ham, | |
| required this.sausage, | |
| required this.spices, | |
| required this.vegetables, | |
| }){ | |
| Future.microtask(_cooking); | |
| } | |
| Future<void> _cooking() async{ | |
| print("🧑🍳"); | |
| print("부대찌개 요리를 시작합니다 !"); | |
| print("🔪${this.ham.productName}과 ${this.sausage.productName}를 자릅니다."); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔪🔪")); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔪🔪🔪")); | |
| String sliceVegetable = this.vegetables.map<String>((FoodIngredient fi) => fi.productName).toList().join(','); | |
| print("🔪${sliceVegetable}들을 자릅니다."); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔪🔪")); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔪🔪🔪")); | |
| print("🍲${this.water.productName} ${this.water.gramme}을 냄비에 넣고 센 불로 3초 동안 끓입니다."); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔥🔥🔥🔥🔥")); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔥🔥🔥🔥🔥")); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔥🔥🔥🔥🔥")); | |
| String spicess = this.spices.map<String>((FoodIngredient fi) => (fi.productName+"(${fi.gramme})")).toList().join(','); | |
| print("🍲${this.water.productName}이 끓기 시작하여 양념 및 재료들을 모두 넣어줍니다."); | |
| print("* 양념 및 재료 : $spicess"); | |
| print("👉5초간 중불로 더 끓입니다."); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔥🔥🔥")); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔥🔥🔥")); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔥🔥🔥")); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔥🔥🔥")); | |
| await Future.delayed(Duration(seconds: 1), () => print("🔥🔥🔥")); | |
| print("그릇에 옯겨 담아 줍니다."); | |
| await Future.delayed(Duration(seconds: 1), () => print("👉🍲")); | |
| this.isCooking = true; | |
| print("🤩 '부대찌개' 가 완성되었습니다!"); | |
| return; | |
| } | |
| } | |
| // 만약 김치찌개 또는 순두부찌개 등을 끓이면 | |
| // '재료'만 바뀌고 '요리를 하는 것' 자체는 같다. | |
| // 무엇을 담을지 등 다르지만 일정량 끓인다는 건 같다. | |
| // 같은 건 같이 묶고, 다른 건 다르게 나눠서 | |
| // 좀 더 쉽게 요리들을 찍어낼 수 없을까? | |
| abstract class Food{ | |
| String name = ""; | |
| void cooking(); | |
| void serve(); | |
| } | |
| abstract class Stew implements Food{ | |
| FoodIngredient water = FoodIngredient(productName: "", gramme: ""); | |
| List<FoodIngredient> spices = []; | |
| List<FoodIngredient> vegetables = []; | |
| List<FoodIngredient> meats = []; | |
| Future<void> boiling({required List<FoodIngredient> fis, required int min, bool isAdd}); | |
| Future<void> cutting({required List<FoodIngredient> ingredients}); | |
| Future<void> showFoodIngredient(); | |
| } | |
| class Jjigae implements Stew{ | |
| @override | |
| String name; | |
| @override | |
| FoodIngredient water; | |
| @override | |
| List<FoodIngredient> spices; | |
| @override | |
| List<FoodIngredient> vegetables; | |
| @override | |
| List<FoodIngredient> meats; | |
| Jjigae({required this.water, required this.vegetables, required this.spices, required this.meats, required this.name}); | |
| @override | |
| Future<void> boiling({required List<FoodIngredient> fis, required int min, bool isAdd = false}) async{ | |
| FoodIngredient boilingIngredients = FoodIngredient(productName: "", gramme: ""); | |
| for(FoodIngredient v in fis){ | |
| boilingIngredients.productName += "${v.productName}_${v.gramme}" + (fis.indexOf(v) == fis.length-1 ? "" : ","); | |
| if(boilingIngredients.gramme.isEmpty){ | |
| boilingIngredients.gramme += v.gramme; | |
| } | |
| else{ | |
| boilingIngredients.gramme = (int.parse(boilingIngredients.gramme.split('g')[0]) + int.parse(v.gramme.split("g")[0])).toString() + "g"; | |
| } | |
| if(fis.indexOf(v) == fis.length-1){ | |
| boilingIngredients.gramme = "총 "+boilingIngredients.gramme; | |
| } | |
| } | |
| return await Future<void>.delayed(Duration(seconds: 1), () async{ | |
| print("${boilingIngredients.productName}(${boilingIngredients.gramme})을 ${this.water.productName} ${this.water.gramme}에 ${isAdd ? '함께 ': ''}넣고 ${min}분 끓입니다."); | |
| print("🔥🔥🔥"); | |
| }); | |
| } | |
| @override | |
| Future<void> cutting({required List<FoodIngredient> ingredients}) async{ | |
| String result = ingredients.map<String>((FoodIngredient fi) => "${fi.productName}(${fi.gramme})").toList().join(','); | |
| await Future.delayed(Duration(seconds: 1), () async{ | |
| print("🔪${result}(들)을 자릅니다."); | |
| print("🔪🔪🔪"); | |
| }); | |
| return; | |
| } | |
| @override | |
| Future<void> cooking() async{ | |
| print(" 🧑🍳"); | |
| this.showFoodIngredient(); | |
| print("${this.name}을(를) 요리를 시작합니다 !"); | |
| await this.cutting(ingredients: this.meats); | |
| await this.cutting(ingredients: this.vegetables); | |
| await this.boiling(fis: this.vegetables, min: 3); | |
| await this.boiling(fis: this.spices, min: 3, isAdd: true); | |
| await this.boiling(fis: this.meats, min: 3, isAdd: true); | |
| return; | |
| } | |
| Future<void> showFoodIngredient() async{ | |
| print("--------------📄 재료 준비-------------"); | |
| print("😈 오늘은 내가 요리사 - ${this.name}"); | |
| print("🍖 "+this.meats.map<String>((FoodIngredient fi) => "${fi.productName}(${fi.gramme})").toList().join(',')); | |
| print("🥦 "+this.vegetables.map<String>((FoodIngredient fi) => "${fi.productName}(${fi.gramme})").toList().join(',')); | |
| print("🧂 "+this.spices.map<String>((FoodIngredient fi) => "${fi.productName}(${fi.gramme})").toList().join(',')); | |
| print("-------------------------------------"); | |
| return; | |
| } | |
| @override | |
| Future<void> serve() async{ | |
| await this.cooking(); | |
| print("그릇에 옯겨 담아 줍니다."); | |
| await Future.delayed(Duration(seconds: 1), () => print("👉🍲")); | |
| print("🤩 '${this.name}' 이(가) 완성되었습니다!\n"); | |
| return; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment