Esempio n. 1
0
 public Order(SerializationInfo info, StreamingContext ctxt)
 {
     this.Customer = (Customer)info.GetValue("Customer", typeof(Customer));
     this.Shop = (Shop)info.GetValue("Shop", typeof(Shop));
     this.Items = (List<OrderItem>)info.GetValue("Items", typeof(List<OrderItem>));
     this.TotalPrice = (decimal)info.GetValue("TotalPrice", typeof(decimal));
     this.State = (OrderState)info.GetValue("State", typeof(OrderState));
     this.Timestamps = (Dictionary<OrderState, DateTime>)info.GetValue("Timestamps", typeof(Dictionary<OrderState, DateTime>));
 }
Esempio n. 2
0
 public Order(Customer customer, Shop shop)
 {
     this.Customer = customer;
     this.Shop = shop;
     this.Items = new List<OrderItem>();
     this.TotalPrice = 0m;
     this.State = OrderState.UnderConstruction;
     this.Timestamps = new Dictionary<OrderState,DateTime>();
     this.Timestamps[this.State] = DateTime.UtcNow;
     this.Shop.AddOrder(this);
 }
Esempio n. 3
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);
        }
 public void addCustomer(string name)
 {
     Customer customer = new Customer(this.CustomerUids, name);
     this.Customers.Add(this.CustomerUids, customer);
     this.CustomerUids++;
 }