static void Main(string[] args) { Console.WriteLine("Пример шаблона проектирования \"Мост\""); var blogApplication = new BlogApplication(new DarkTheme()); var storeApplication = new StoreApplication(new LightTheme()); var webSite = new WebSite(new LightTheme(), new DarkTheme()); blogApplication.Init(); Console.WriteLine(); storeApplication.Init(); Console.WriteLine(); Console.WriteLine("Модифицируем реализацию "); storeApplication.Themes = new Theme[1] { new DarkTheme() }; storeApplication.Init(); Console.WriteLine(); webSite.Init(); Console.WriteLine(); Console.ReadKey(); }
static void Main(string[] args) { // this is a logger. It logs StreamWriter logger = new StreamWriter("../../../../ef-log.txt"); IStoreApp app = new StoreApplication(logger); int input = 0; // main menu while (input != 9) { Menu: Console.Clear(); Console.WriteLine("(1) Place order\n" + "(2) Add customer\n" + "(3) Display customers\n" + "(4) Display orders by customer\n" + "(5) Display orders by location\n" + "(6) Display all orders\n" + "(7) Add inventory to location\n" + "(8) Add new product\n" + "(9) Quit"); try { input = System.Convert.ToInt32(Console.ReadLine()); // Yes, I used a goto statement, fight me. if (input < 1 || input > 9) { goto Menu; } } // oh no, another one catch (FormatException) { goto Menu; } Console.Clear(); switch (input) { case 1: PlaceOrder(app); break; case 2: AddNewCustomer(app); break; case 3: DisplayCustomers(app); break; case 4: DisplayOrdersByCustomer(app); break; case 5: DisplayOrdersByLocation(app); break; case 6: DisplayOrders(app); break; case 7: AddInventoryToLocation(app); break; case 8: AddProduct(app); break; } } }