public string Visit(Fish fish) { return("Rửa sạch bằng nước ấm"); }
public string Visit(Fish fish) { return("Chiên cá với dầu ở 120 độ C"); }
private void button5_Click(object sender, EventArgs e) { Recipe recipe = new Recipe(listcomponents, textBox1.Text); List <Recipe> recipes = new List <Recipe>(); try { string raw = File.ReadAllText(@"..\..\DataSource\Test.json"); dynamic list = JsonConvert.DeserializeObject <dynamic>(raw); if (list != null) { foreach (dynamic element in list) { Recipe recipe1 = new Recipe((string)element.Name); foreach (dynamic c in element.component_List) { Component component; if (c.Name == "Fish") { component = new Fish(); } else if (c.Name == "Carrot") { component = new Carrot(); } else if (c.Name == "Potato") { component = new Potato(); } else if (c.Name == "Carrot") { component = new Carrot(); } else if (c.Name == "Chicken") { component = new Chicken(); } else if (c.Name == "Coconut") { component = new Coconut(); } else if (c.Name == "Milk") { component = new Milk(); } else if (c.Name == "Shrimp") { component = new Shrimp(); } else if (c.Name == "Taro") { component = new Taro(); } else if (c.Name == "Bubble tea") { component = new Bubble_tea(); } else if (c.Name == "Beef") { component = new Beef(); } else { throw new Exception(); } component.Quantity = c.Quantity; foreach (dynamic v in c.visitors) { IVisitor visitor; if (v.Type == 1) { visitor = new ChopVisitor(); } else if (v.Type == 2) { visitor = new FryVisitor(); } else if (v.Type == 3) { visitor = new WashVisitor(); } else if (v.Type == 4) { visitor = new BoilVisitor(); } else { throw new Exception(); } component.visitors.Add(visitor); } recipe1.component_List.Add(component); } recipes.Add(recipe1); } } } catch { // } recipes.Add(recipe); string data = JsonConvert.SerializeObject(recipes, Formatting.Indented); File.WriteAllText(@"..\..\DataSource\Test.json", data); this.Close(); }
public Recipe_adapter(Dictionary <string, string> a, Recipe recipe) { string jsonString; //this.component_List = recipe.component_List; this.Name = recipe.Name; Component component; foreach (KeyValuePair <string, string> s in a) { for (int i = 0; i < recipe.component_List.Count; i++) { if (recipe.component_List[i].Name == s.Key && s.Key != s.Value) { if (s.Value == "Fish") { component = new Fish(); } else if (s.Value == "Carrot") { component = new Carrot(); } else if (s.Value == "Potato") { component = new Potato(); } else if (s.Value == "Chicken") { component = new Chicken(); } else if (s.Value == "Coconut") { component = new Coconut(); } else if (s.Value == "Coffee") { component = new Coffee(); } else if (s.Value == "Milk") { component = new Milk(); } else if (s.Value == "Noodle") { component = new Noodle(); } else if (s.Value == "Shrimp") { component = new Shrimp(); } else if (s.Value == "Taro") { component = new Taro(); } else if (s.Value == "Rice") { component = new Rice(); } else if (s.Value == "Bubble tea") { component = new Bubble_tea(); } else if (s.Value == "Tea") { component = new Tea(); } else if (s.Value == "Beef") { component = new Beef(); } else { throw new Exception(); } component.Quantity = recipe.component_List[i].Quantity; component.visitors = recipe.component_List[i].visitors; component_List.Add(component); } else if (recipe.component_List[i].Name == s.Key) { if (!component_List.Contains(recipe.component_List[i])) { component_List.Add(recipe.component_List[i]); } } } } jsonString = JsonConvert.SerializeObject(this.component_List, Formatting.Indented); File.AppendAllText("D:\\check_adapt_com.json", jsonString); }
public string Visit(Fish fish) { return("Chặt cá, bỏ ra, bỏ nội tạng"); }
public string Visit(Fish fish) { return("Đun trong nước sôi nhỏ lửa 20 phút"); }