Пример #1
0
        public static OrderClass Decode(String encoded)
        {
            var        parts       = encoded.Split('/');
            String     senderId    = parts[0];
            int        cardNo      = int.Parse(parts[1]);
            int        amount      = int.Parse(parts[2]);
            OrderClass orderObject = new OrderClass();

            orderObject.SenderId = senderId;
            orderObject.CardNo   = cardNo;
            orderObject.Amount   = amount;
            return(orderObject);
        }
Пример #2
0
 public static void changePrice(double price)
 {
     if (price < chickenPrice)
     {
         if (priceCut != null)
         {
             priceCut(price);
         }
     }
     chickenPrice = price;
     String          processing     = myApplication.buffer.getOneCell();
     OrderClass      orderToProcess = Decoder.Decode(processing);
     OrderProcessing process        = new OrderProcessing(orderToProcess, price);
 }
Пример #3
0
        public void retailerFunc()
        {
            ChickenFarm chicken = new ChickenFarm();

            price = chicken.getPrice();
            Console.WriteLine("Store{0} initial chicken Price: {1}", Thread.CurrentThread.Name, price);
            while (true)
            {
                if (needorder == true)
                {
                    OrderClass order = new OrderClass();
                    order.SenderId = Thread.CurrentThread.Name;
                    order.CardNo   = 5000 + int.Parse(Thread.CurrentThread.Name);
                    order.Amount   = 25;
                    String encodedorder = Encoder.Encode(order);
                    orderSent = DateTime.Now.TimeOfDay;
                    myApplication.buffer.setOneCell(encodedorder);
                    needorder = false;
                }
            }
        }
Пример #4
0
        //public static void confirmOrder(OrderClass orderObject, int unitPrice)
        public OrderProcessing(OrderClass orderObject, double unitPrice)
        {
            double tax = .05;
            double shippingHandling;

            if (orderObject.CardNo >= 5000 && orderObject.CardNo <= 7000)
            {
                int    NoOfChickens = orderObject.Amount;
                double total        = 0;
                total = NoOfChickens * unitPrice;
                if (NoOfChickens < 50)
                {
                    shippingHandling = 100;
                }
                else
                {
                    shippingHandling = 50;
                }
                total = total + (total * tax) + shippingHandling;

                Console.WriteLine("Order from {0}\n\tAmount: {1}\n\tCredit Card Number: {2}\n\tChicken Price: {3}\n\tOrder Cost: {4}",
                                  orderObject.SenderId, orderObject.Amount, orderObject.CardNo, unitPrice, total);
            }
        }