Ejemplo n.º 1
0
        // Checking to see if Override works, pegacorn will have a specific attack
        public void MegladonInheritsPolymorph()
        {
            string superPower = "Speed flight";
            // string superPower2 = "healer";
            string name   = "aldo";
            int    length = 100;

            Megalodon mega = new Megalodon(superPower, name, length);


            Assert.Equal(mega.Attack(), mega.Attack());
            Assert.Equal(mega.Heal(), mega.Heal());
            Assert.IsAssignableFrom <ISwim>(mega);
        }
Ejemplo n.º 2
0
        public static bool CreateMegaladon()
        {
            {
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                try
                {
                    Console.WriteLine("Name the Zoo's Megaladon:");
                    string name = Console.ReadLine();

                    Console.WriteLine("What is the Megaladon's super power?");
                    string superPower = Console.ReadLine();

                    Console.WriteLine("What is Megaladon's BodyLength?");
                    int length = int.Parse(Console.ReadLine());

                    Megalodon megaladon  = new Megalodon(superPower, name, length);
                    int       bodyLength = megaladon.BodyLength;
                    bool      attack     = megaladon.Attack();
                    bool      heal       = megaladon.Heal();

                    Console.ReadKey();
                    return(true);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Megaladon - Exception thrown: {ex.Message}");
                    return(false);
                }
            }
        }