コード例 #1
0
ファイル: Program.cs プロジェクト: enrique-aguilar/Farm
        static void Main(string[] args)
        {
            try
            {
                Sheep terry = new Sheep();
                terry.Name = "Terry";

                Horses seabiscuit = new Horses();
                seabiscuit.Name = "Seabiscuit";

                Chicken albertEggstein = new Chicken();
                albertEggstein.Name = "Albert Eggstein";

                Cow bessie = new Cow();
                bessie.Name = "Bessie";

                terry.Speak();
                Console.WriteLine();
                seabiscuit.Eat();
                Console.WriteLine();
                albertEggstein.Use();
                Console.WriteLine();
                bessie.InterestingFact();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.ReadLine();
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            Rabbits  rab     = new Rabbits();
            Cows     cow     = new Cows();
            Sheeps   sheep   = new Sheeps();
            Chickens chicken = new Chickens();
            Horses   horse   = new Horses();



            string name  = "";
            bool   check = false;

            while (check == false)

            {
                Console.WriteLine("\nSelect which animal you would like to know about.\n" + "1.Rabbits" + " 2.Cows" + " 3.Sheeps" + " 4.Chickens" + " 5.Horses" + " 6. Quit");
                Console.Write("\t\tMy option is: ");
                name = Console.ReadLine();
                switch (name)
                {
                case "1":
                    Console.Clear();
                    rab.Speak();
                    rab.Eat();
                    rab.Produce();
                    rab.Loveto();

                    check = false;
                    break;

                case "2":
                    Console.Clear();
                    cow.Speak();
                    cow.Eat();
                    cow.Produce();
                    cow.Loveto();


                    check = false;
                    break;

                case "3":
                    Console.Clear();
                    sheep.Speak();
                    sheep.Eat();
                    sheep.Produce();
                    sheep.Loveto();


                    check = false;
                    break;

                case "4":
                    Console.Clear();
                    chicken.Speak();
                    chicken.Eat();
                    chicken.Produce();
                    chicken.Loveto();


                    check = false;
                    break;

                case "5":
                    Console.Clear();
                    horse.Speak();
                    horse.Eat();
                    horse.Produce();
                    horse.Loveto();


                    check = false;
                    break;

                case "6":
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\nThanks for playing. Duces (>^_^>) (<^_^<)\n");


                    check = true;
                    break;

                default:
                    Console.WriteLine("Invalid Selection");
                    check = false;
                    break;
                }
            }
        }