Exemplo n.º 1
0
        public void Orca_Eats_Narwhal()
        {
            Orca    eater = new Orca();
            Narwhal food  = new Narwhal();

            Assert.True(eater.Eat(food));
        }
Exemplo n.º 2
0
        public void Narwhal_Eats_Other()
        {
            Narwhal             eater = new Narwhal();
            OtherEdibleCritters food  = new OtherEdibleCritters();

            Assert.True(eater.Eat(food));
        }
Exemplo n.º 3
0
        public void TestNarwhalClassInheritsBehavior()
        {
            Narwhal narwhal = new Narwhal()
            {
                Name = "Spike"
            };
            string input    = narwhal.Eats();
            string expected = ($"{narwhal.Name} loves to eat chocolate ice cream");

            Assert.Equal(expected, input);
        }
Exemplo n.º 4
0
        public Task <CommandResult> Execute(string[] fullCommand, string[] rawArgs, Dictionary <string, string> variables,
                                            string[] flags)
        {
            if (rawArgs.Length < 2)
            {
                return(Task.FromResult(new CommandResult(false, "At least 2 argument is needed")));
            }

            var path   = rawArgs[0];
            var volume = rawArgs[1];

            var narwhal    = new Narwhal(false);
            var errors     = narwhal.Load(volume, path);
            var enumerable = errors as string[] ?? errors.ToArray();

            return(Task.FromResult(!enumerable.Any()
                ? new CommandResult(true, $"Loaded into volume <{volume}>!")
                : new CommandResult(false, enumerable.JoinBy("\n"))));
        }
Exemplo n.º 5
0
    {/// <summary>
     /// Main to instantiate animals, make array and show them; then make fly array for flying animals from IFly interface
     /// </summary>
     /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");
            Animals[] animals = new Animals[5];
            IFly[]    fly     = new IFly[3];

            //instantiate 5 animals

            BaldEagle baldEagle = new BaldEagle()
            {
                Name = "Birdie", BreathsPerMinute = 25, HasWings = true, Wingspan = 100
            };
            Pegasus pegasus = new Pegasus()
            {
                Name = "Wild horse", CanFloat = true, Wingspan = 200, Velocity = 200
            };
            Elephant elephant = new Elephant()
            {
                Name = "Dumbo", HasTrunk = true, HasWings = false, Velocity = 25
            };
            Penguin penguin = new Penguin()
            {
                Name = "Bill", CoatType = "feathers"
            };
            Narwhal narwahl = new Narwhal()
            {
                Name = "Spike", HasHorn = true
            };

            // fly array contains 3 animals
            fly[0] = baldEagle;
            fly[1] = pegasus;
            fly[2] = elephant;

            // animal array contains 5 animals
            animals[0] = baldEagle;
            animals[1] = pegasus;
            animals[2] = elephant;
            animals[3] = penguin;
            animals[4] = narwahl;

            for (int i = 0; i < fly.Length; i++)
            {
                var canFly = fly[i];
                if (canFly is Pegasus)
                {
                    var    flier = (Pegasus)canFly;
                    string peg   = flier.Speed();
                    Console.WriteLine($"{peg}");
                }
                else if (canFly is BaldEagle)
                {
                    var    flier = (BaldEagle)canFly;
                    string eagle = flier.Speed();
                    Console.WriteLine($"{eagle}");
                }
                else if (canFly is Elephant)
                {
                    var    flier = (Elephant)canFly;
                    string elle  = flier.Speed();
                    Console.WriteLine($"{elle}");
                }
            }

            //for loop to display 5 animals

            for (int i = 0; i < animals.Length; i++)
            {
                Console.WriteLine($"{ animals[i].Name} is a zoo animal");
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            // make animals
            Skunk   skunk   = new Skunk();
            Weasel  weasel  = new Weasel();
            Bear    bear    = new Bear();
            Lion    lion    = new Lion();
            Wolf    wolf    = new Wolf();
            Narwhal narwhal = new Narwhal();
            Dolphin dolphin = new Dolphin();
            Orca    orca    = new Orca();

            // make dinner
            IAmDinner rat      = new OtherEdibleCritters();
            IAmDinner mole     = new OtherEdibleCritters();
            IAmDinner guppy    = new OtherEdibleCritters();
            IAmDinner salmon   = new OtherEdibleCritters();
            IAmDinner tuna     = new OtherEdibleCritters();
            IAmDinner sturgeon = new OtherEdibleCritters();
            IAmDinner bass     = new OtherEdibleCritters();

            // setting the stage
            Console.WriteLine("Chaos at the zoo!  All of the enclosures have been torn down by angry environmentalists, and the animals are out of control!");

            // skunk eats mole and births 3 babies
            Console.WriteLine("");
            skunk.Eat(mole);
            skunk.GiveBirth(3);

            // weasel eats rat and births 6 babies
            Console.WriteLine("");
            weasel.Eat(rat);
            weasel.GiveBirth(6);

            // lion and wolf each feast at the newly stocked weasel buffet
            Console.WriteLine("");
            lion.Eat(weasel);
            wolf.Eat(weasel);

            // wolf is expecting, so she also eats a bass
            Console.WriteLine("");
            wolf.Eat(bass);
            wolf.GiveBirth(3);

            // lion also had some buns in the oven
            Console.WriteLine("");
            lion.GiveBirth(4);

            // bear went out for dinner, and then went home to have babies and a nap
            Console.WriteLine("");
            bear.Travel();
            bear.Eat(salmon);
            bear.Travel();
            bear.GiveBirth(1);

            // meanwhile, in the water, everyone had babies!
            Console.WriteLine("");
            narwhal.GiveBirth(1);
            orca.GiveBirth(1);
            dolphin.GiveBirth(1);

            // ...and got hungry
            Console.WriteLine("");
            narwhal.Eat(guppy);
            dolphin.Eat(sturgeon);
            orca.Eat(narwhal);
            orca.Eat(dolphin);

            Console.ReadLine();
        }
Exemplo n.º 7
0
        public void Narwhal_CanBeInstantiated()
        {
            Animal narwhal = new Narwhal();

            Assert.Equal("narwhal", narwhal.Species);
        }
Exemplo n.º 8
0
        public void Narwhal_Swims()
        {
            Cetacean traveler = new Narwhal();

            Assert.Equal("swim", traveler.Travel());
        }