Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Turtle turtle1 = new Turtle("Mertle", 72);

            turtle1.Eat("Lettuce");
            turtle1.Eat("Lettuce");
            turtle1.ShowTime("bar-mitzvah");
        }
        public static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");

            var    babyTurtle = new Turtle("Jim");
            Turtle turtle     = new Turtle("Mertle", 72);

            Console.WriteLine(turtle.Description);
            turtle.Eat();
            turtle.Eat("Lettuce");
            turtle.ShowTime("bar-mitzvah");
            turtle.ShowTime("birthday");
            babyTurtle.ShowTime("birthday");

            Scorpion scorpion = new Scorpion("Steven");

            scorpion.Attack();
            //Console.WriteLine($"{turtle1.Name} is {turtle1.Age } years old. {turtle1.Size}");
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public void WarriorEatingNullFruitThrowsArgumentNullException()
        {
            // Arrange
            var   turtle = new Turtle('1');
            Apple apple  = null;


            // Act and Assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  turtle.Eat(apple));
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            Console.WriteLine("***************************  Toy  ***************************************");

            var babyCube = new BabyCube(10, "VTech");

            babyCube.Describe();
            babyCube.SetLevel(1);

            Console.WriteLine("***************************  Birds  ***************************************");

            //Birds (the parent constructor was executed first before the child constructor)
            var goose = new Goose(true, 2, "seeds", "gray");

            Console.WriteLine("***************************  Pets  ***************************************");

            //Pets(child can have its own methods Bark or Climb)
            var puppy = new Puppy(false, 4, "bones", "yellow");

            puppy.Bark();

            Console.WriteLine("---------------------------------");

            var kitty = new Kitty(false, 4, "fish", "yellow");

            kitty.Climb();

            Console.WriteLine("***************************  Crawls  ***************************************");

            //Crawls(child can use its implemented interface methods and call the parent public methods)
            var turtle = new Turtle(false, 4, "insects", "brown");

            turtle.Crawl();
            turtle.Eat();
            //turtle.Confidential();
            turtle.MakePublic();

            Console.WriteLine("---------------------------------");

            var crocodile = new Crocodile(false, 4, "fish", "gray");

            crocodile.Sleep();
            crocodile.Crawl();

            Console.WriteLine("---------------------------------");

            var tortoise = new Tortoise(true, 4, "grass", "gray");

            tortoise.Sleep();
            tortoise.Crawl();
            tortoise.Walk();
        }
Ejemplo n.º 5
0
        public void WarriorGainsPowerWhenItEatsApple()
        {
            // Arrange
            var turtle   = new Turtle('1');
            var apple    = new Apple();
            var oldPower = turtle.Power;

            // Act
            turtle.Eat(apple);

            // Assert
            var newPower = turtle.Power;

            Assert.Greater(newPower, oldPower);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This method shows inheritance
        /// </summary>
        public static void ReptilesCanMakeSoundsAndEat()
        {
            Turtle turti = new Turtle()
            {
                Name = "Turtie"
            };

            Console.WriteLine($"Hi! My name is {turti.Name} and I make {turti.Sound()} noises!");
            Console.WriteLine(turti.Eat());
            Console.WriteLine();
            Console.ReadLine();


            Snake snek = new Snake()
            {
                Name = "Snek"
            };

            Console.WriteLine($"Hi! My name is {snek.Name} and I make {snek.Sound()} noises!");
            Console.WriteLine(snek.Eat());
            Console.ReadLine();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

//created a new object of Tiger ,Teddy is a Tiger
            Tiger tiger = new Tiger();

            string name = tiger.Speak("Ted");

            Console.WriteLine($"Hello,my name is {name}, i am a tiger");
            Console.WriteLine("My color is:" + tiger.color);
            Console.WriteLine($"I have { tiger.legs} legs");
            tiger.Eat();
            tiger.Sleep();


            Console.WriteLine("**************");
            //created a panda object

            Panda panda = new Panda();

            panda.name = "Sunshine";
            Console.WriteLine($"Hi! I am a panda my name is {panda.name}");
            panda.Eat();
            panda.Sleep();

            Console.WriteLine("**************");
            //created a Monkey object
            Monkey monkey = new Monkey();

            monkey.name = "King";
            Console.WriteLine($"Hi! I am a monkey my name is {monkey.name}");
            monkey.Eat();
            monkey.Sleep();

            Console.WriteLine("**************");
            //created a Tutle object

            Turtle turtle = new Turtle();

            turtle.shell = 1;
            turtle.name  = "Alex";
            Console.WriteLine($"Hi I am turtle,my name is {turtle.name} and i have {turtle.shell} shell");
            turtle.Eat();
            turtle.Move();
            Console.WriteLine(turtle.ControlBodyTemperature());
            turtle.Sleep();


            Console.WriteLine("**************");
            //created a Owl object

            Owl owl = new Owl();

            owl.Sleep();
            owl.Eat();
            owl.sound();
            Console.WriteLine("I can fly:" + owl.fly());


            Console.WriteLine("**************");
            //created a Ostrich object

            Ostrich ostrich = new Ostrich();

            ostrich.Sleep();
            ostrich.Eat();
            Console.WriteLine("I can fly:" + ostrich.fly());
            Console.WriteLine("**************");
            Console.WriteLine("**************");
            string foodOne = tiger.Hunt(monkey);

            //string foodTwo=tiger.Hunt(ostrich);
            //Console.WriteLine($"I can hunt {foodOne} and {foodTwo}");
            Console.WriteLine($"I can hunt  {foodOne}");
            Console.WriteLine("**************");
            Console.WriteLine(monkey.Mimic("jump and clap"));
        }