Exemple #1
0
        static void Main(string[] args)
        {
            SpiceHound spicy   = new SpiceHound();
            SweetTooth sweet   = new SweetTooth();
            Buffet     buffet1 = new Buffet();

            Console.WriteLine("Spicy is eating...");
            while (!spicy.IsFull())
            {
                spicy.Consume(buffet1.Serve());
            }
            Console.WriteLine($"Spicy ate {spicy.ConsumptionHistory.Count} items.");

            Console.WriteLine("Sweet is eating...");
            while (!sweet.IsFull())
            {
                sweet.Consume(buffet1.Serve());
            }
            Console.WriteLine($"Spicy ate {sweet.ConsumptionHistory.Count} items.");

            if (spicy.ConsumptionHistory.Count > sweet.ConsumptionHistory.Count)
            {
                Console.WriteLine("Spicy ate more!");
            }
            else if (spicy.ConsumptionHistory.Count < sweet.ConsumptionHistory.Count)
            {
                Console.WriteLine("Sweet ate more!");
            }
            else
            {
                Console.WriteLine("It's a tie!");
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Buffet     yummy = new Buffet();
            SweetTooth kyle  = new SweetTooth();
            SpiceHound dude  = new SpiceHound();

            while (!kyle.IsFull)
            {
                kyle.Consume(yummy.Serve());
            }
            if (kyle.ConsumptionHistory.Count > dude.ConsumptionHistory.Count)
            {
                Console.WriteLine($"SweetTooth had the most items consumed with {kyle.ConsumptionHistory.Count} items!");
            }
            else
            {
                Console.WriteLine($"SweetTooth had the most items consumed with {dude.ConsumptionHistory.Count} items!");
            }
        }