Example #1
0
        static void Main(string[] args)
        {
            Buffet     lux  = new Buffet();
            SweetTooth jack = new SweetTooth();
            SpiceHound john = new SpiceHound();

            jack.Consume(lux.Serve());
            System.Console.WriteLine(jack.isFull);

            jack.Consume(lux.Serve());
            System.Console.WriteLine(jack.isFull);

            john.Consume(lux.Serve());
            System.Console.WriteLine(john.isFull);
            john.Consume(lux.Serve());
            System.Console.WriteLine(john.isFull);
            john.Consume(lux.Serve());
            System.Console.WriteLine(john.isFull);

            if (jack.FoodHistory.Count > john.FoodHistory.Count)
            {
                foreach (IConsumable eat in jack.FoodHistory)
                {
                    System.Console.WriteLine(eat);
                }
            }
            else
            {
                foreach (IConsumable eat in john.FoodHistory)
                {
                    System.Console.WriteLine(eat.Name);
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Buffet      AllYouCanEat = new Buffet();
            SweetTooth  Dave         = new SweetTooth("Dave");
            SpiceHound  Rick         = new SpiceHound("Rick");
            IConsumable item         = AllYouCanEat.Serve();

            Dave.Consume(item);
            Dave.Consume(item);
            Dave.Consume(item);
            Dave.Consume(item);
            Dave.Consume(item);
            Rick.Consume(item);
            Rick.Consume(item);
            Rick.Consume(item);
            Rick.Consume(item);
            Rick.Consume(item);
            if (Dave.ConsumptionHistory.Count > Rick.ConsumptionHistory.Count)
            {
                Console.WriteLine($"Dave consumed {Dave.ConsumptionHistory.Count} items but Rick only had {Rick.ConsumptionHistory.Count}.");
            }
            else if (Rick.ConsumptionHistory.Count > Dave.ConsumptionHistory.Count)
            {
                Console.WriteLine($"Rick consumed {Rick.ConsumptionHistory.Count} items but Dave only had {Dave.ConsumptionHistory.Count}.");
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Buffet     buffet = new Buffet();
            SpiceHound john   = new SpiceHound();
            SweetTooth jane   = new SweetTooth();

            Console.WriteLine(john.Consume(buffet.Serve()));
            Console.WriteLine(john.Consume(buffet.Serve()));
            Console.WriteLine(john.Consume(buffet.Serve()));
            Console.WriteLine(john.Consume(buffet.Serve()));
            Console.WriteLine(john.Consume(buffet.Serve()));
            Console.WriteLine(john.Consume(buffet.Serve()));
            Console.WriteLine(john.Consume(buffet.Serve()));
            Console.WriteLine(john.Consume(buffet.Serve()));

            Console.WriteLine("\n");

            Console.WriteLine(jane.Consume(buffet.Serve()));
            Console.WriteLine(jane.Consume(buffet.Serve()));
            Console.WriteLine(jane.Consume(buffet.Serve()));
            Console.WriteLine(jane.Consume(buffet.Serve()));
            Console.WriteLine(jane.Consume(buffet.Serve()));
            Console.WriteLine(jane.Consume(buffet.Serve()));
            Console.WriteLine(jane.Consume(buffet.Serve()));
            Console.WriteLine(jane.Consume(buffet.Serve()));
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Ninja Buffet!");
            Buffet Yum = new Buffet();
            Ninja  Joe = new SpiceHound("Joe");
            Ninja  Moe = new SweetTooth("Moe");

            while (!Joe.IsFull || !Moe.IsFull)
            {
                Joe.Consume(Yum.Serve());
                Moe.Consume(Yum.Serve());
            }
            Console.WriteLine($"Joe ate {Joe.ConsumptionHistory.Count} items.\nMoe ate {Moe.ConsumptionHistory.Count} items.");
            if (Joe.ConsumptionHistory.Count > Moe.ConsumptionHistory.Count)
            {
                Console.WriteLine("Joe wins!");
            }
            else if (Moe.ConsumptionHistory.Count > Joe.ConsumptionHistory.Count)
            {
                Console.WriteLine("Moe wins!");
            }
            else
            {
                Console.WriteLine("It's a tie!");
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            Buffet     ayce  = new Buffet();
            SweetTooth alfie = new SweetTooth();
            SpiceHound gomez = new SpiceHound();

            alfie.Consume(ayce);
            foreach (IConsumable item in alfie.ConsumptionHistory)
            {
                Console.WriteLine(item.Name);
            }
            Console.WriteLine($"This ninja had {alfie.ConsumptionHistory.Count} items");
            Console.WriteLine("========================================");

            gomez.Consume(ayce);
            foreach (IConsumable item in gomez.ConsumptionHistory)
            {
                Console.WriteLine(item.Name);
            }
            Console.WriteLine($"This ninja had {gomez.ConsumptionHistory.Count} items");
            Console.WriteLine("========================================");

            if (alfie.ConsumptionHistory.Count > gomez.ConsumptionHistory.Count)
            {
                Console.WriteLine("Alfie had more items!");
            }
            else if (alfie.ConsumptionHistory.Count < gomez.ConsumptionHistory.Count)
            {
                Console.WriteLine("Gomez had more items!");
            }
            else
            {
                Console.WriteLine("Both ninjas had the same items");
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            Buffet     Meal = new Buffet();
            SweetTooth Alice = new SweetTooth();
            SpiceHound Yoda = new SpiceHound();
            int        count = 0, countsweet = 0, countspice = 0;
            string     name1, name2;

            while (!Alice.IsFull)
            {
                count++;
                countsweet++;
                Alice.Consume(Meal.Serve());
            }
            while (!Yoda.IsFull)
            {
                count++;
                countspice++;
                Yoda.Consume(Meal.Serve());
            }
            if (countsweet > countspice)
            {
                name1 = "SweetTooth Alice";
                name2 = "SpiceHound Yoda";
            }
            else
            {
                name1 = "SpiceHound Yoda";
                name2 = "SweetTooth Alice";
            }
            Console.WriteLine($"{name1} has consumed more than {name2} and the number of items consumed: {count}");
        }
Example #7
0
        static void Main(string[] args)
        {
            // instantiate a Buffet, a SweetTooth, and a SpiceHound.
            Buffet     buff   = new Buffet();
            SweetTooth sweetT = new SweetTooth();
            SpiceHound spiceH = new SpiceHound();

            // have both the SweetTooth and Spice hound "Consume" from the Buffet until Full.
            Console.WriteLine("## SWEETTOOTH ##");
            while (!sweetT.IsFull)
            {
                sweetT.Consume(buff.Serve());
            }
            Console.WriteLine("########################################################");
            Console.WriteLine("## SPICEHOUND ##");
            while (!spiceH.IsFull)
            {
                spiceH.Consume(buff.Serve());
            }

            Console.WriteLine("########################################################");

            // write to the console which of the two consumed the most items and the number of items consumed.
            List <IConsumable> allHistory = new List <IConsumable>();

            foreach (var thing in sweetT.ConsumptionHistory)
            {
                allHistory.Add(thing);
            }
            foreach (var thing in spiceH.ConsumptionHistory)
            {
                allHistory.Add(thing);
            }

            var sortHistory = allHistory.GroupBy(item => item.Name);
            var sorted      = sortHistory.OrderByDescending(group => group.Count());

            Console.WriteLine("## GROUP ITEMS BY NUMBER OF ITEMS CONSUMED ##");
            foreach (var group in sorted)
            {
                int count = 0;
                foreach (var item in group)
                {
                    count++;
                }
                Console.WriteLine(group.Key + " - " + count);
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            //Ninja Sam = new Ninja(); cannot make an object of an abstract class
            Buffet     NinjaJoint = new Buffet();
            SweetTooth Scott      = new SweetTooth();
            SpiceHound Jared      = new SpiceHound();

            while (!Scott.IsFull)
            {
                Scott.Consume(NinjaJoint.Serve());
            }
            while (!Jared.IsFull)
            {
                Jared.Consume(NinjaJoint.Serve());
            }
            if (Scott.FoodHistory.Count > Jared.FoodHistory.Count)
            {
                Console.WriteLine($"SweetTooth consumed the most number of food items at {Scott.FoodHistory.Count}");
            }
            else
            {
                Console.WriteLine($"SpiceHound consumed the most number of food items at {Jared.FoodHistory.Count}");
            }
            // foreach(Food item in NinjaJoint.Menu)
            // {
            //     Console.WriteLine(item.Name);
            // }
            // Console.WriteLine(bacon.Name);
            // while(!Sam.IsFull)
            // {
            //     Sam.eat(NinjaJoint.Serve());
            // }
            string castSpell = Console.ReadLine();

            Console.WriteLine(castSpell + " has been cast!");
        }
Example #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World of the Ninja Buffet!");
            Buffet      NinjaBuffet = new Buffet();
            IConsumable item        = NinjaBuffet.Serve();
            IConsumable item1       = NinjaBuffet.Serve();
            IConsumable item2       = NinjaBuffet.Serve();
            SweetTooth  naruto      = new SweetTooth("Naruto");

            naruto.Consume(item);
            naruto.Consume(item);
            naruto.Consume(item);
            naruto.Consume(item);
            naruto.Consume(item);
            naruto.Consume(item);
            naruto.Consume(item1);
            naruto.Consume(item1);
            naruto.Consume(item1);
            naruto.Consume(item1);
            naruto.Consume(item1);
            naruto.Consume(item1);
            naruto.Consume(item2);
            naruto.Consume(item2);
            SpiceHound noriko = new SpiceHound("Noriko");

            Console.WriteLine(" ");
            noriko.Consume(item);
            noriko.Consume(item);
            noriko.Consume(item);
            noriko.Consume(item1);
            noriko.Consume(item1);
            noriko.Consume(item1);
            noriko.Consume(item1);
            noriko.Consume(item2);
            noriko.Consume(item2);
            noriko.Consume(item2);
            noriko.Consume(item2);
        }