예제 #1
0
        public bool Checkout(Wallet wallet)
        {
            bool inShop = true;

            DisplayOrder();
            Interaction.AddSpace();
            Console.WriteLine("You currently have $" + wallet.CheckCash() + " in your wallet.");
            Console.WriteLine("Would you like to continue checking out? [Y/N]");
            bool contWithOrder = Interaction.AskYesNoQuestion("Can you say that again? Would you like to continue checking out? [Y/N]");

            if (contWithOrder)
            {
                if (wallet.RemoveCash(OrderTotal()))
                {
                    foreach (KeyValuePair <Product, int> orderpair in Order)
                    {
                        RemoveFromShopInventory(orderpair.Key, orderpair.Value);
                    }
                    Order = new Dictionary <Product, int>();
                }
                else
                {
                    Console.WriteLine("And I made all those items for you...");
                }
                inShop = false;
            }
            return(inShop);
        }
예제 #2
0
        public void DisplayOrder()
        {
            Interaction.AddSpace();
            Console.WriteLine("Your current order:");
            Console.WriteLine("Bread: ");
            double breadSubTotal = 0;

            foreach (KeyValuePair <Product, int> breadPair in Order.Where(pair => pair.Key.Type == "Bread"))
            {
                Bread bread = (Bread)breadPair.Key;
                Console.WriteLine(" + Qty " + (breadPair.Value) + " - " + (bread.IsGlutenFree ? "Gluten free bread " : "Bread ") + "that is " + (bread.IsSliced ? "sliced" : "a whole loaf"));
                Console.WriteLine("Price: $" + breadPair.Key.DefaultCost.ToString() + " each");
                breadSubTotal += (breadPair.Key.DefaultCost * breadPair.Value);
            }
            Console.WriteLine("Bread Subtototal: " + breadSubTotal.ToString());
            Console.WriteLine("");
            Console.WriteLine("Pastry: ");
            char[] vowels         = { 'a', 'e', 'i', 'o', 'u' };
            double pastrySubtotal = 0;

            foreach (KeyValuePair <Product, int> pastryPair in Order.Where(pair => pair.Key.Type == "Pastry"))
            {
                Pastry pastry = (Pastry)pastryPair.Key;
                Console.WriteLine(" + Qty " + (pastryPair.Value) + " - " + (pastry.IsSavory ? "Savory " : "Sweet ") + "pastry in the shape of a" + (vowels.Contains(pastry.Shape[0]) ? "n " + pastry.Shape : " " + pastry.Shape));
                Console.WriteLine("Price: $" + pastryPair.Key.DefaultCost.ToString() + " each");
                pastrySubtotal += (pastryPair.Key.DefaultCost * pastryPair.Value);
            }
            Console.WriteLine("Pastry Subtototal: " + pastrySubtotal.ToString());
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("Total Cost: " + (breadSubTotal + pastrySubtotal).ToString());
        }
예제 #3
0
        public bool BakeryActions(Wallet wallet)
        {
            bool inShop = true;

            Interaction.AddSpace();
            string toDo = Interaction.UserInput();

            if (toDo == "order")
            {
                RequestProduct();
            }
            else if (toDo == "show")
            {
                ProductsListing();
            }
            else if (toDo == "checkout")
            {
                inShop = Checkout(wallet);
            }
            else if (toDo == "leave")
            {
                inShop = LeaveShop();
            }
            return(inShop);
        }
예제 #4
0
        public Wallet BankAction(Wallet wallet)
        {
            string[] options = new string[] { "withdraw", "deposit", "leave" };
            DisplayMoney(wallet);
            Console.WriteLine("What would you like to do? [Withdraw, Deposit, Leave]");
            string response = Interaction.AskOptionsQuestion(options, "What was that again? What would you like to do? [Withdraw, Deposit, Leave]");

            if (response == "withdraw" || response == "deposit")
            {
                Console.WriteLine("How much would you like to " + response + "?");
                double value = Interaction.AskPositiveDoubleQuestion("Come again? How much would you like to " + response + "?");

                if (response == "withdraw")
                {
                    Withdraw(value);
                    wallet.AddCash(value);
                }
                else
                {
                    if (wallet.RemoveCash(value))
                    {
                        Deposit(value);
                    }
                }

                Interaction.AddSpace();
                Console.WriteLine("Current values: ");
                DisplayMoney(wallet);

                Console.WriteLine("");
            }

            return(wallet);
        }