static private void BuyProduct(Seller seller, Purchaser purchaser) { seller.ShowProducts(); int productNumber = Convert.ToInt32(Console.ReadLine()); Product product = seller.Sell(productNumber); if (product != null) { purchaser.BuyProduct(product); Console.WriteLine("Покупка завершена успешно!"); } }
static void Main(string[] args) { Seller seller = new Seller(); Purchaser purchaser = new Purchaser(); int action = 0; while (action != 4) { switch (action) { case 1: seller.ShowProducts(); break; case 2: BuyProduct(seller, purchaser); break; case 3: purchaser.ShowProducts(); break; case 4: break; } Console.Write("Введите номер действия, которое хотите совершить: \n" + "1) Вывести весь товар у продавца \n" + "2) Купить товар \n" + "3) Вывести товар у покупателя \n" + "4) Выход\n"); action = Convert.ToInt32(Console.ReadLine()); } seller.ShowProducts(); purchaser.ShowProducts(); }