public List <Teacher> Search() { SearchS search; switch (flag) { case 0: { search = new DOM(); break; } case 1: { search = new SAX(); break; } case 2: { search = new LINQ(); break; } default: { search = null; break; } } return(search.Search(teacher)); }
public void SearchFood() { OutputTable.Text = ""; Food food = new Food(); food.Dish = ""; food.Cuisine = ""; food.Course = ""; food.Weight = ""; food.Description = ""; food.Price = ""; try { if (DishCheckBox.Checked && DishBox.Text != "") { food.Dish = DishBox.SelectedItem.ToString(); } if (CuisineCheckBox.Checked && CuisineBox.Text != "") { food.Cuisine = CuisineBox.SelectedItem.ToString(); } if (CourseCheckBox.Checked && CourseBox.Text != "") { food.Course = CourseBox.SelectedItem.ToString(); } if (WeightCheckBox.Checked && WeightBox.Text != "") { food.Weight = WeightBox.SelectedItem.ToString(); } if (DescriptionCheckBox.Checked && DescriptionBox.Text != "") { food.Description = DescriptionBox.SelectedItem.ToString(); } if (PriceCheckBox.Checked && PriceBox.Text != "") { food.Price = PriceBox.SelectedItem.ToString(); } } catch { food.Dish = "Error"; food.Cuisine = "Error"; food.Course = "Error"; food.Weight = "Error"; food.Description = "Error"; food.Price = "Error"; } IStrategy strategy = new DOM(); if (!DOM.Checked && !SAX.Checked && !LINQ.Checked) { MessageBox.Show("Please select strategy"); return; } if (DOM.Checked) { strategy = new DOM(); } if (SAX.Checked) { strategy = new SAX(); } if (LINQ.Checked) { strategy = new LINQ(); } List <Food> foods = strategy.Search(food); int i = 0; foreach (Food f in foods) { OutputTable.Text += ++i + ")\n"; OutputTable.Text += "Dish: " + f.Dish + "\n"; OutputTable.Text += "Cuisine: " + f.Cuisine + "\n"; OutputTable.Text += "Course: " + f.Course + "\n"; OutputTable.Text += "Weight: " + f.Weight + "\n"; OutputTable.Text += "Description: " + f.Description + "\n"; OutputTable.Text += "Price: " + f.Price + "\n\n\n"; } }