示例#1
0
        static void Main(string[] args)
        {
            log log1 = new log("log.txt");

            seller a = new seller("Даша", log1);

            product [] p = new product[5];
            p[0] = new product("хлеб", 20);
            p[1] = new product("масло", 60);
            p[2] = new product("молоко", 40);
            p[3] = new product("каша", 35);
            p[4] = new product("чай", 100);

            buyer b1 = new buyer("Петя", 100, log1);

            b1.l.Add(p[0]);
            b1.l.Add(p[3]);
            b1.stay_to_queue(a);

            buyer b2 = new buyer("Маша", 100, log1);

            b2.l.Add(p[2]);
            b2.l.Add(p[4]);
            b2.stay_to_queue(a);

            a.work();
        }
示例#2
0
        public int punch_goods(buyer b)
        {
            int summ = 0;

            foreach (product p in b.l)
            {
                summ += p.price;
            }
            return(summ);
        }
示例#3
0
 public void work()
 {
     while (queue.Count > 0)
     {
         buyer  b    = queue.Peek();
         int    summ = punch_goods(b);
         string str  = "Продавец пробил товары " + b.name + " на сумму " + summ.ToString();
         w_l.save(str);
         if (b.pay(summ))
         {
             profit += summ;
             str     = "Покупка совершена. Сумма в кассе =  " + profit.ToString();
             w_l.save(str);
         }
         else
         {
             str = "У покупателя недостаточно средств";
             w_l.save(str);
         }
         queue.Dequeue();
     }
 }