Skip to content

Instantly share code, notes, and snippets.

@doyle-flutter
Created August 28, 2021 04:00
Show Gist options
  • Save doyle-flutter/d451a4832f61fd91f69ce62f3c2c8ecf to your computer and use it in GitHub Desktop.
Save doyle-flutter/d451a4832f61fd91f69ce62f3c2c8ecf to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(Sys());
class FoodIngredient{
String productName;
String gramme;
FoodIngredient({required this.productName,required this.gramme});
}
abstract class Food{
void serve();
Future<void> cooking();
}
abstract class Jjigae implements Food{
final String name;
final FoodIngredient water;
final List<FoodIngredient> spices;
final List<FoodIngredient> vegetables;
final List<FoodIngredient> meats;
Jjigae(this.name, this.water, this.spices, this.vegetables, this.meats);
Future<void> cutting();
Future<void> boiling();
Future<void> cooking() async{
print("😈");
print("${this.name}을(λ₯Ό) μš”λ¦¬λ₯Ό μ‹œμž‘ν•©λ‹ˆλ‹€ !");
return await Future<void>.delayed(Duration(seconds: 1), (){});
}
Future<void> serve() async{
await this.cooking();
await this.showFoodIngredient();
await this.cutting();
await this.boiling();
print("그릇에 옯겨 λ‹΄μ•„ μ€λ‹ˆλ‹€.");
await Future.delayed(Duration(seconds: 1), () => print("πŸ‘‰πŸ²"));
print("'${this.name}' 이(κ°€) μ™„μ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€!");
print("🀩");
print("\n");
return;
}
Future<void> cboiling({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("πŸ”₯"*min);
});
}
Future<void> cCutting({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;
}
Future<void> showFoodIngredient() async{
print("--------------πŸ“„ 재료 μ€€λΉ„-------------");
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 await Future<void>.delayed(Duration(seconds: 1), (){});
}
}
class KimchiJji extends Jjigae{
KimchiJji({
required String name,
required FoodIngredient water,
required List<FoodIngredient> spices,
required List<FoodIngredient> vegetables,
required List<FoodIngredient> meats
}) : super(name, water, spices, vegetables, meats);
@override
Future<void> boiling() async{
await this.cboiling(fis: this.meats, min: 3);
await this.cboiling(fis: this.vegetables, min: 3);
}
@override
Future<void> cutting() async{
await this.cCutting(ingredients: this.meats);
await this.cCutting(ingredients: this.vegetables);
}
}
class BuJJi extends Jjigae{
final List<FoodIngredient> seafoods;
BuJJi({
required this.seafoods,
required String name,
required FoodIngredient water,
required List<FoodIngredient> spices,
required List<FoodIngredient> vegetables,
required List<FoodIngredient> meats}) : super(name, water, spices, vegetables, meats);
@override
Future<void> boiling() async{
await this.cboiling(fis: this.seafoods, min: 4);
await this.cboiling(fis: this.meats, min: 3);
await this.cboiling(fis: this.vegetables, min: 3);
}
@override
Future<void> cutting() async{
print("πŸ”ͺ πŸ¦πŸ¦‘πŸ™πŸŸ ${this.seafoods.map<String>((FoodIngredient fi) => fi.productName).toList().join(',')}듀을 μ†μ§ˆν•©λ‹ˆλ‹€");
print("πŸ”ͺπŸ”ͺπŸ”ͺ");
await this.cCutting(ingredients: this.meats);
await this.cCutting(ingredients: this.vegetables);
}
@override
Future<void> showFoodIngredient() async{
await super.showFoodIngredient();
print("+++ πŸ¦πŸ¦‘πŸ™πŸŸ ${this.seafoods.map<String>((FoodIngredient fi) => fi.productName).toList().join(',')}");
print("-------------------------------------");
return await Future<void>.delayed(Duration(seconds: 1), () {});
}
}
class Sundubu extends Jjigae{
final List<FoodIngredient> seafoods;
Sundubu({
required this.seafoods,
required String name,
required FoodIngredient water,
required List<FoodIngredient> spices,
required List<FoodIngredient> vegetables,
required List<FoodIngredient> meats}) : super(name, water, spices, vegetables, meats);
@override
Future<void> boiling() async{
await this.cboiling(fis: this.seafoods, min: 4);
await this.cboiling(fis: this.meats, min: 3);
await this.cboiling(fis: this.vegetables, min: 3);
}
@override
Future<void> cutting() async{
print("πŸ”ͺ πŸ¦πŸ¦‘πŸ™πŸŸ ${this.seafoods.map<String>((FoodIngredient fi) => fi.productName).toList().join(',')}듀을 μ†μ§ˆν•©λ‹ˆλ‹€");
print("πŸ”ͺπŸ”ͺπŸ”ͺ");
await this.cCutting(ingredients: this.meats);
await this.cCutting(ingredients: this.vegetables);
}
@override
Future<void> showFoodIngredient() async{
await super.showFoodIngredient();
print("+++ πŸ¦πŸ¦‘πŸ™πŸŸ ${this.seafoods.map<String>((FoodIngredient fi) => fi.productName).toList().join(',')}");
print("-------------------------------------");
return await Future<void>.delayed(Duration(seconds: 1), () {});
}
}
class Sys extends StatelessWidget {
const Sys({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Main(),
);
}
}
class Main extends StatefulWidget {
Main({Key? key}) : super(key: key);
@override
_MainState createState() => _MainState();
}
class _MainState extends State<Main> {
final Jjigae buJi = BuJJi(
name: "🍲 λΆ€λŒ€μ°Œκ°œ",
seafoods: [
FoodIngredient(productName: "μƒˆμš°", gramme: "30g"),
],
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"),
]
);
final Jjigae kimchiJji = KimchiJji(
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"),
]
);
final Jjigae sundubu = Sundubu(
name: "🍲 μˆœλ‘λΆ€μ°Œκ°œ",
seafoods: [
FoodIngredient(productName: "μƒˆμš°", gramme: "30g"),
FoodIngredient(productName: "바지락", gramme: "30g"),
],
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: "300g"),
]
);
bool clickCheck = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("μ°Œκ°œλ“€λ“€λ“€ 03"),),
body: IgnorePointer(
ignoring: this.clickCheck,
child: Container(
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [this.buJi, this.kimchiJji, this.sundubu].map<Widget>(
(Jjigae jjigea) => MaterialButton(
color: Colors.blue,
textColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
minWidth: 200.0,
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Text(jjigea.name, style: TextStyle(fontSize: 20.0),),
onPressed: () async{
setState(() {
this.clickCheck = true;
});
await jjigea.serve();
setState(() {
this.clickCheck = false;
});
},
)
).toList(),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment