Exemple #1
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;
     }
 }