コード例 #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!");
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Buffet     yummy = new Buffet();
            SweetTooth dylan = new SweetTooth();
            SpiceHound dude  = new SpiceHound();

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