示例#1
0
        void AssignAnimal()
        {
            Animal animal = null;

            Console.WriteLine("Choose the animal Horse or Donkey");
            string choice = Console.ReadLine().ToUpper();

            switch (choice)
            {
            case "HORSE":
                animal = new Horse();
                break;

            case "DONKEY":
                animal = new Donkey();
                break;

            default:
                Console.WriteLine("Invalid Choice");
                break;
            }
            PullCart(animal);
        }
        void AssignAnimal()
        {
            Animals animals = null;

            Console.WriteLine("Choose the animal horse or donkey");
            string Choice = Console.ReadLine().ToUpper();

            switch (Choice)
            {
            case "HORSE":
                animals = new Horse();
                break;

            case "DONKEY":
                animals = new Donkey();
                break;

            default:
                Console.WriteLine();
                break;
            }
            pullCart(animals);
        }