Пример #1
0
        static void Main(string[] args)
        {
            SweetTooth Chelsea   = new SweetTooth("Chelsea");
            SpiceHound Joseph    = new SpiceHound("Joseph");
            Buffet     FoodTruck = new Buffet();

            while (Chelsea.IsFull != true)
            {
                IConsumable edible = FoodTruck.Serve();
                Chelsea.Consume(edible);
            }

            while (Joseph.IsFull != true)
            {
                IConsumable edible = FoodTruck.Serve();
                Joseph.Consume(edible);
            }

            Console.WriteLine($"Chelsea ate {Chelsea.ConsumptionHistory.Count} items");
            Console.WriteLine($"Joseph ate {Joseph.ConsumptionHistory.Count} items");

            if (Chelsea.ConsumptionHistory.Count > Joseph.ConsumptionHistory.Count)
            {
                Console.WriteLine("Chelsea ate more items.");
            }
            else
            {
                Console.WriteLine("Chelsea ate more items.");
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Buffet     serverBuffet = new Buffet();
            SweetTooth bob          = new SweetTooth("Bob");

            while (!bob.IsFull)
            {
                bob.Consume(serverBuffet.Serve());
            }
            SpiceHound jack = new SpiceHound("Jack");

            while (!jack.IsFull)
            {
                jack.Consume(serverBuffet.Serve());
            }
        }