Пример #1
0
        static void Main(string[] args)
        {
            var woodPecker = new WoodPecker();
            var snake      = new Snake("Johnny");
            var tiger      = new Tiger();

            HandleAnimal(woodPecker);
            HandleAnimal(snake);
            HandleAnimal(tiger);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Animal Lion  = new Lion();
            Animal Tiger = new Tiger();

            Tiger.SetMe("tiger", 100);
            Tiger.Show();
            Console.WriteLine();
            Lion.SetMe("Lion", 200);
            Lion.Show();
            Console.ReadKey();
        }
Пример #3
0
        static void Main(string[] args)
        {
            BMW bmw = new BMW();

            bmw.Engine();
            Car car = new BMW();

            car.Door();
            bmw.SteerWheel();
            Animal.Eat();
            Tiger.Eat();
            Console.ReadLine();
        }
Пример #4
0
        static void Main(string[] args)
        {
            Animal animal = new Animal()
            {
                Id   = 1,
                Name = "Ben",
                Type = "Dog",
            };

            Dog majlo = new Dog()
            {
                Id    = 2,
                Name  = "Majlo",
                Type  = "Dog",
                Breed = "Husky"
            };

            Cat garfild = new Cat()
            {
                Id       = 3,
                Name     = "Garfild",
                Lazyness = "Very"
            };

            Tiger tiger = new Tiger()
            {
                Id       = 4,
                Name     = "Tiger",
                Lazyness = "Non",
            };

            animal.Eat();
            majlo.Eat();
            garfild.Eat();
            garfild.Meow();
            tiger.Eat();
            tiger.Meow();
            tiger.PrintInfo();

            Console.ReadLine();
        }
Пример #5
0
 static void Main(string[] args)
 {
     Animal animal;
     Console.WriteLine("Would you raise a tiger or a puppy?");
     Console.WriteLine("1 = tiger, 2 = puppy");
     int choice2;
     again:
     try
     {
         choice2 = int.Parse(Console.ReadLine());
     }
     catch (Exception)
     {
         goto again;
     }
     switch (choice2)
     {
         case 1:
             animal = new Tiger();
             break;
         case 2:
             animal = new Puppy();
             break;
         default:
             goto again;
     }
     int choice = 0;
     while (animal.isAlive())
     {
         try_again:
         Console.WriteLine("Animal status age "+ animal.Age+" fullness "+ animal.Fullness+" happiness "+ animal.Happiness);
         Console.WriteLine("1 Drink");
         Console.WriteLine("2 Eat");
         Console.WriteLine("3 Pee");
         Console.WriteLine("4 Stay");
         Console.WriteLine("5 Sit");
         Console.WriteLine("6 Pet");
         Console.WriteLine("7 MakeSound");
         Console.WriteLine("8 Mood");
         try
         {
             choice = int.Parse(Console.ReadLine());
         }
         catch (Exception)
         {
             goto try_again;
         }
         switch (choice)
         {
             case 1:
                 animal.Drink();
                 break;
             case 2:
                 animal.Eat();
                 break;
             case 3:
                 animal.Pee();
                 break;
             case 4:
                 animal.Stay();
                 break;
             case 5:
                 animal.Sit();
                 break;
             case 6:
                 animal.Pet();
                 break;
             case 7:
                 animal.MakeSound();
                 break;
             case 8:
                 Console.WriteLine(animal.Mood());
                 break;
         }
         goto try_again;
     }
 }