Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, and welcome to the Farm.  Please hit 'ENTER' to meat our fun little friends");
            Console.ReadLine();

            Cat p1 = new Cat();

            Console.WriteLine("Hello, I am a Cat");
            p1.name();
            p1.eat();
            p1.sound();
            p1.like();
            Console.WriteLine("Would you like to meet my friend the Cow? Press 'ENTER'");
            Console.ReadLine();

            Cow c1 = new Cow();

            Console.WriteLine("Hi, I am a Cow");
            c1.name();
            c1.eat();
            c1.sound();
            c1.like();
            Console.WriteLine("I have a furry little friend named Dog, would you like to meet him? Press 'ENTER'");
            Console.ReadLine();

            Dog d1 = new Dog();

            Console.WriteLine("Well Hello, I am a Dog");
            d1.name();
            d1.eat();
            d1.sound();
            d1.like();
            Console.WriteLine("I would like to take you to meet the stinky one here at the farm.  " +
                              "I call her Fat Amy, but the farmer always call's her his ex-wife.  Would you like to meet her? Press 'ENTER'");
            Console.ReadLine();

            Pig a1 = new Pig();

            Console.WriteLine("Oink, I am a Pig Oink");
            a1.name();
            a1.eat();
            a1.sound();
            a1.like();
            Console.WriteLine("I would take you to a friend to meet, but no one likes me becuase I am a stinky fat pig.  " +
                              "If you want to leave though, just press 'ENTER'");
            Console.ReadLine();

            Console.WriteLine("Thank you for visiting, hope you come again.");
            Console.ReadLine();
        }
        private static void makePig()
        {
            try {
                Console.WriteLine("What do you want to name your pig?");
                animalName = Console.ReadLine(); //User names animal
                Pig pig1 = new Pig(animalName);  //Pig object is created and the user defined name is transfered to be used by the Pig class
                Console.WriteLine("Each animal can do things. Some things every animal can do are eat, make noise, and move.");
                Console.WriteLine("However, only pigs can root in the mud.");
                Console.WriteLine($"What do you {animalName} to do? Enter '1' to eat, '2' to make noise, '3' to move, '4' to root, and '5' to have a good time");
                int action = int.Parse(Console.ReadLine()); //gets value for switch statement to run a specific method
                switch (action)                             //implements methods applicable to specific animal
                {
                case 1:
                    pig1.Eat();
                    break;

                case 2:
                    pig1.MakeNoise();
                    break;

                case 3:
                    pig1.Move(animalName);
                    break;

                case 4:
                    pig1.Root();
                    break;

                case 5:
                    Animal.Party();
                    break;

                default:
                    Console.WriteLine("Sorry, that wasn't a valid action to choose from.");
                    break;
                }
                ChooseAnimal();//allows user to reselect another animal to create
            }
            catch (FormatException Fex)
            { Console.WriteLine(Fex.Message); }
            catch (DuplicateWaitObjectException Dex)
            { Console.WriteLine(Dex.Message); }
            catch (Exception ex)
            { Console.WriteLine(ex.Message); }
        }