Esempio n. 1
0
        private void interactiveShopping()
        {
            customer = ssd.Customers[0];
            Console.WriteLine("~~~### Welcome " + customer.Name + " to the interactive SmartShopping experience!!! ###~~~");
            shop = ssd.Shops[0];
            customer.enterShop(shop);
            Console.WriteLine("You have entered " + shop.Name);
            string nextAction = "0";
            while (true)
            {
                if (nextAction.Equals("9"))
                    break;
                Console.WriteLine("What would you like to do? \n 1) Add products to basket, 2) Place order or 3) View statistics?");
                nextAction = Console.ReadLine();
                if (nextAction.Equals("1"))
                {
                    goShop();
                }
                else if (nextAction.Equals("2"))
                {
                    customer.PlaceOrder();
                    break;
                }
                else if (nextAction.Equals("3"))
                {
                    showStats();
                }
                else
                    continue;
            }
            Console.WriteLine("You are now the shop. You have received the following order:");
            Order order = customer.Order;
            Console.WriteLine(order.ToString());
            Console.WriteLine("Press any key when you are done packaging the order");
            Console.ReadLine();
            shop.DeliverOrder(order);
            Console.WriteLine("You are now the costumer again! You have been called to the desk and should pay for your order.");
            Console.WriteLine(order.ToString());
            Console.Write("Please enter the amount to pay: ");
            decimal payment = decimal.Parse(Console.ReadLine());
            if (payment < order.TotalPrice)
                Console.WriteLine("Get your fat ass outta here!");
            else if (payment > order.TotalPrice)
            {
                decimal moneyBack = payment - order.TotalPrice;
                Console.WriteLine("Well, that was a bit too much! Here is your money back: " + moneyBack);
                customer.ReceiveOrder();
            }
            else
            {
                Console.WriteLine("Thank you very much, have a nice day!");
                customer.ReceiveOrder();
            }

            ssd.Save(filename);
        }