private void RemoveShop(Plaza plaza) { System.Console.WriteLine("Enter the shop name: "); plaza.RemoveShop(plaza.FindShopByName(Console.ReadLine())); System.Console.WriteLine("Removed!"); Console.ReadKey(); }
private void EnterShop(Plaza plaza) { Console.WriteLine("Shop name: "); ShowShopMenu(plaza.FindShopByName(Console.ReadLine())); }
bool ChooseMainPlaza() { string choice = AnyInput("Please choose an option..."); switch (choice) { case "1": //is the plaza opened? Console.Clear(); if (myPlaza.IsOpen()) { Console.WriteLine("The plaza is opened."); } else { Console.WriteLine("The plaza is closed"); } AnyInput("Press any key to continue..."); return(true); case "2": // open the plaza Console.Clear(); myPlaza.Open(); Console.WriteLine("The plaza has just opened."); Thread.Sleep(1000); return(true); case "3": // close plaza Console.Clear(); myPlaza.Close(); Console.WriteLine("The plaza has just closed."); Thread.Sleep(1000); return(true); case "4": // list the shops Console.Clear(); try { if (myPlaza.GetShops().Count > 0) { foreach (Shop aShop in myPlaza.GetShops()) { Console.WriteLine(aShop.ToString()); } } else { Console.WriteLine("There are no shops in the Plaza."); } } catch (PlazaIsClosedException) { Console.WriteLine("The Plaza is closed."); } AnyInput("Press any key to continue..."); return(true); case "5": // add new shop Console.Clear(); string shopName = AnyInput("The name of the new shop?: "); string owner = AnyInput("The owner of the new shop?: "); try { Shop shop = new ShopImpl(shopName, owner); myPlaza.AddShop(shop); Console.WriteLine("A new shop has added the plaza."); } catch (PlazaIsClosedException) { Console.WriteLine("The Plaza is closed."); } catch (ShopAlreadyExistsException) { Console.WriteLine("This shop is already exist."); } Thread.Sleep(1000); return(true); case "6": // remove a shop Console.Clear(); shopName = AnyInput("The shop name to remove?: "); try { myPlaza.RemoveShop(myPlaza.FindShopByName(shopName)); } catch (PlazaIsClosedException) { Console.WriteLine("The Plaza is closed."); } catch (NoSuchShopException) { Console.WriteLine("No shop is exist with this name."); } Thread.Sleep(1000); return(true); case "7": // entering a shop Console.Clear(); shopName = AnyInput("Which shop you want to enter?: "); try { bool shopbool = true; while (shopbool) { Console.WriteLine("Entering the shop."); Thread.Sleep(1000); MenuShop(myPlaza.FindShopByName(shopName)); shopbool = ChooseShop(myPlaza.FindShopByName(shopName)); } } catch (PlazaIsClosedException) { Console.WriteLine("The Plaza is closed."); } catch (NoSuchShopException) { Console.WriteLine("No shop is exist with this name."); } Thread.Sleep(1000); return(true); case "8": // listing the cart Console.Clear(); if (myPlaza.IsOpen()) { if (cart.Count == 0) { Console.WriteLine("There is no product in the cart."); } else { for (int index = 0; index < cart.Count; index++) { Console.Write(cart[index].ToString()); Console.WriteLine(", Price: " + prices[index].ToString()); } } } else { Console.WriteLine("The plaza is closed."); } Console.WriteLine(); AnyInput("Press any key to continue..."); return(true); case "0": // Exit program Console.Clear(); return(false); default: return(true); } }