Exemplo n.º 1
0
        static void Submenu(PetClass anypet)
        {
            Console.WriteLine("\n\n\t\tPress 1 to feed " + anypet.Name +
                              "\n\t\tPress 2 to take " + anypet.Name + " the doctor " +
                              "\n\t\tPress 3 to play with " + anypet.Name +
                              "\n\t\tPress 4 to view current status of " + anypet.Name +
                              "\n\t\tPress 5 to rename  " + anypet.Name +
                              "\n\n\t\tPress 0 return to the shelter", anypet.Name);
            bool   runnapp = true;
            string input;

            do
            {
                input = Console.ReadLine();

                switch (input)
                {
                case "1":    //Feed your pet
                    Console.WriteLine("\t\t=====You have fed {0}===== ", anypet.Name);
                    anypet.Feed();
                    //anypet.Status();
                    break;

                case "2":     //Visit the veterinarian
                    Console.WriteLine("\t\t===== You  have taken {0} to the veterinarian ===== ", anypet.Name);
                    anypet.PetMaintenance();
                    //anypet.Status();
                    break;

                case "3":     //Play with your pet
                    Console.WriteLine("\t\t===== You  have played with {0} ===== ", anypet.Name);
                    anypet.Play();
                    //anypet.Status();
                    break;

                case "4":    //View status of your pet
                    Shelter.Status(anypet);
                    break;

                case "5":     //Rename Pet
                    Console.WriteLine("Please type the name in which you would like your pet to be called");
                    string new_name = Console.ReadLine();
                    anypet.Rename(new_name);
                    Console.WriteLine("Your Pet has New name " + new_name);
                    break;

                case "0":    //Close the program
                    runnapp = false;
                    Console.WriteLine("Press 2 to return back to the shelter to view all the pets we have");
                    break;

                default:
                    Console.WriteLine("Invalid response please select option from the menu again");
                    break;
                }
            } while (runnapp);
        }
Exemplo n.º 2
0
        public static void Status(PetClass pet) //work at home linq
        {
            RoboticPetClass robotic;
            OrganicPetClass organic;


            if (pet.GetType() == typeof(RoboticPetClass))
            {
                robotic = pet as RoboticPetClass;
                robotic.Status();
            }
            else if (pet.GetType() == typeof(OrganicPetClass))
            {
                organic = pet as OrganicPetClass;
                organic.Status();
            }
        }