public Customer(SerializationInfo info, StreamingContext ctxt) { this.Uid = (int)info.GetValue("Uid", typeof(int)); this.State = (CustomerState)info.GetValue("State", typeof(CustomerState)); this.Name = (string)info.GetValue("Name", typeof(string)); this.Order = (Order)info.GetValue("Order", typeof(Order)); this.Shop = (Shop)info.GetValue("Shop", typeof(Shop)); this.OrderHistory = (List<Order>)info.GetValue("OrderHistory", typeof(List<Order>)); }
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>)); }
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); }
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 enterShop(Shop shop) { this.Shop = shop; this.Order = new Order(this, this.Shop); this.State = CustomerState.Shopping; }
public void addShop(string name) { Shop shop = new Shop(this.ShopUids, name); this.Shops.Add(this.ShopUids, shop); this.ShopUids++; }