Ejemplo n.º 1
0
            public static Int32 reevaluatePrice()
            {
                Int32 newPrice = 5000 / ChickenFarm.getNumChickens();

                if (newPrice < 1)
                {
                    newPrice++;
                }
                return(newPrice);
            }
Ejemplo n.º 2
0
        public void orderProcessing()
        {
            float tax, shipping;
            Int32 subtotal, total;

            if (pOrder.getAmount() <= (ChickenFarm.getNumChickens() - 2))
            {
                if ((pOrder.getCardNum() > 999) && (pOrder.getCardNum() < 10000))
                {
                    subtotal = pOrder.getUnitPrice() * pOrder.getAmount();
                    tax      = subtotal * TAXRATE;
                    shipping = pOrder.getAmount() * SHIPPINGRATE;
                    total    = (Int32)(subtotal + tax + shipping);
                    ChickenFarm.setNumChickens(ChickenFarm.getNumChickens() - pOrder.getAmount());

                    // Order finished timestamp
                    DateTime endTime = DateTime.Now.ToUniversalTime();
                    TimeSpan span    = endTime.Subtract(pOrder.getStartTime());

                    //send receipt (output to console)
                    Console.Out.WriteLine("Retailer {0} bought {1} chickens for a total of ${2} at price {3} in {4}ms!", pOrder.getThreadId(), pOrder.getAmount(), total, pOrder.getUnitPrice(), span.TotalMilliseconds);
                }
            }
        }