Пример #1
0
        static void Main(string[] args)
        {
            Shelter shelter    = new Shelter();
            Pet     roboticPet = new RoboticPet();
            Pet     organicPet = new OrganicPet();

            Console.WriteLine("Hello! Welcome to Virtual Pets, let's create an organic pet to start");
            Console.WriteLine("What is your pet's name?");
            organicPet.SetName(Console.ReadLine());
            Console.WriteLine("What is your pet's species?");
            organicPet.SetSpecies(Console.ReadLine());
            Console.WriteLine($"{organicPet.GetName()} The {organicPet.GetSpecies()} exists!");
            shelter.AddOrganicPet(organicPet);
            Console.WriteLine("Press Enter to start playing");
            Console.ReadLine();

            bool whilePlaying = true;

            do
            {
                shelter.TickAllPets();
                Console.WriteLine("What do you want to do with your pet?");
                Console.WriteLine("1. Feed a pet");
                Console.WriteLine("2. Play with a pet");
                Console.WriteLine("3. Take a pet to the vet");
                Console.WriteLine("4. Check pet status");
                Console.WriteLine("5. Adopt pet");
                Console.WriteLine("6. Add robotic pet");
                Console.WriteLine("7. Add organic pet");
                Console.WriteLine("8. Review Shelter list");
                Console.WriteLine("9. Feed all pets");
                Console.WriteLine("10. Play with all pets");
                Console.WriteLine("11. Take all pets to the vet");
                Console.WriteLine("12. Quit");
                string menuChoice = Console.ReadLine();
                Console.Clear();
                switch (menuChoice)
                {
                case "1":
                {
                    shelter.PrintAllPets();
                    Console.WriteLine("Which pet would you like to feed?");
                    int petNumber   = Convert.ToInt32(Console.ReadLine());
                    Pet petToChoose = shelter.FindPetByIndex(petNumber - 1);
                    petToChoose.Feed();
                    Console.WriteLine($"You fed {petToChoose.Name}!");
                    petToChoose.CheckPetStatus();
                    break;
                }

                case "2":
                {
                    shelter.PrintAllPets();
                    Console.WriteLine("Which pet would you like to play with?");
                    int petNumber   = Convert.ToInt32(Console.ReadLine());
                    Pet petToChoose = shelter.FindPetByIndex(petNumber - 1);
                    petToChoose.Play();
                    Console.WriteLine($"You played with {petToChoose.Name}!");
                    petToChoose.CheckPetStatus();
                    break;
                }

                case "3":
                {
                    shelter.PrintAllPets();
                    Console.WriteLine("Which pet would you like to take to the vet?");
                    int petNumber   = Convert.ToInt32(Console.ReadLine());
                    Pet petToChoose = shelter.FindPetByIndex(petNumber - 1);
                    petToChoose.SeeDoctor();
                    Console.WriteLine($"You took {petToChoose.Name} to the vet!");
                    petToChoose.CheckPetStatus();
                    break;
                }

                case "4":
                {
                    shelter.PrintAllPets();
                    Console.WriteLine("Which pet would you like to check up on?");
                    int petNumber   = Convert.ToInt32(Console.ReadLine());
                    Pet petToChoose = shelter.FindPetByIndex(petNumber - 1);
                    petToChoose.CheckPetStatus();
                    break;
                }

                case "5":
                {
                    shelter.PrintAllPets();
                    Console.WriteLine("Which pet will be adopted? This pet will be permanently removed from the shelter");
                    int petNumber   = Convert.ToInt32(Console.ReadLine());
                    Pet petToChoose = shelter.FindPetByIndex(petNumber - 1);
                    shelter.RemovePetFromList(petToChoose);
                    Console.WriteLine($"{petToChoose.GetName()} Found a new home :)");
                    break;
                }

                case "6":
                {
                    roboticPet = new RoboticPet();
                    Console.WriteLine("What is your pet's name?");
                    roboticPet.SetName(Console.ReadLine());
                    Console.WriteLine("What is your pet's species?");
                    roboticPet.SetSpecies(Console.ReadLine());
                    shelter.AddRoboticPet(roboticPet);
                    Console.WriteLine($"{roboticPet.GetName()} The Robo-{roboticPet.GetSpecies()} exists!");
                    break;
                }

                case "7":
                {
                    organicPet = new OrganicPet();
                    Console.WriteLine("What is your pet's name?");
                    organicPet.SetName(Console.ReadLine());
                    Console.WriteLine("What is your pet's species?");
                    organicPet.SetSpecies(Console.ReadLine());
                    shelter.AddOrganicPet(organicPet);
                    Console.WriteLine($"{organicPet.GetName()} The {organicPet.GetSpecies()} exists!");
                    break;
                }

                case "8":
                {
                    shelter.PrintAllPetDetails();
                    break;
                }

                case "9":
                {
                    shelter.FeedAllPets();
                    break;
                }

                case "10":
                {
                    shelter.PlayWithAllPets();

                    break;
                }

                case "11":
                {
                    shelter.AllPetsSeeDoctor();
                    break;
                }

                case "12":
                {
                    whilePlaying = false;
                    break;
                }

                default:
                {
                    Console.WriteLine("Please enter a valid number");
                    break;
                }
                }
            } while (whilePlaying);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello! Welcome to Virtual Pets");

            Pet        pet        = new Pet();
            OrganicPet organicPet = new OrganicPet();
            RoboticPet roboticPet = new RoboticPet();
            Shelter    shelter    = new Shelter();

            Console.WriteLine("\nAdmit your first pet into the Shelter");
            bool stillThinking = false;

            while (stillThinking == false)
            {
                Console.WriteLine("Would you like to admit an (1)Organic Pet or a (2)Robotic Pet?");
                string petType = Console.ReadLine();
                if (petType == "1")
                {
                    pet = new OrganicPet();
                    pet.CreatePet();
                    shelter.AddPetToShelter(pet);
                    stillThinking = true;
                }
                else if (petType == "2")
                {
                    pet = new RoboticPet();
                    pet.CreatePet();
                    shelter.AddPetToShelter(pet);
                    stillThinking = true;
                }
                else
                {
                    Console.WriteLine("Select (1) or (2)");
                }
            }

            bool keepThinking = true;

            while (keepThinking)
            {
                Console.WriteLine("1. Feed your pet");
                Console.WriteLine("2. Take your pet to the vet");
                Console.WriteLine("3. Play with your pet");
                Console.WriteLine("4. Admit a New Pet Into Shelter");
                Console.WriteLine("5. Show Pet Status");
                Console.WriteLine("6. Feed all pets");
                Console.WriteLine("7. Take all pets to the vet");
                Console.WriteLine("8. Play with all pets");
                Console.WriteLine("9. See all pets in shelter");
                Console.WriteLine("10. Show status of all pets");
                Console.WriteLine("11. Select A Pet");
                Console.WriteLine("12. Adopt a Pet from the Shelter");
                Console.WriteLine("13. Exit");

                string userSelection = Console.ReadLine();
                shelter.TickAllPets();
                Console.Clear();

                switch (userSelection)
                {
                case "1":
                    pet.Feed();
                    break;

                case "2":
                    pet.SeeVet();
                    break;

                case "3":
                    pet.Play();
                    break;

                case "4":
                    Console.WriteLine("Would you like to admit an (1)Organic Pet or a (2)Robotic Pet?");
                    string petType = Console.ReadLine();
                    if (petType == "1")
                    {
                        pet = new OrganicPet();
                        pet.CreatePet();
                        shelter.AddPetToShelter(pet);
                    }
                    else if (petType == "2")
                    {
                        pet = new RoboticPet();
                        pet.CreatePet();
                        shelter.AddPetToShelter(pet);
                    }
                    else
                    {
                        Console.WriteLine("Select (1) or (2)");
                    }
                    break;

                case "5":
                    pet.ShowPetStatus();
                    break;

                case "6":
                    shelter.FeedAllPets();
                    break;

                case "7":
                    shelter.SeeVetAllPets();
                    break;

                case "8":
                    shelter.PlayAllPets();
                    break;

                case "9":
                    shelter.SeeListOfPets();
                    break;

                case "10":
                    shelter.SeeStatusOfPets();
                    break;

                case "11":
                    shelter.SeeListOfPets();
                    Console.WriteLine("Select a pet(#)");
                    int petSelection = Convert.ToInt32(Console.ReadLine());
                    pet = shelter.SelectPet(petSelection);
                    Console.WriteLine($"You selected {pet.Name} the {pet.Species}");
                    break;

                case "12":
                    shelter.SeeListOfPets();
                    Console.WriteLine("Select a pet(#) to Adopt");
                    int adoptSelection = Convert.ToInt32(Console.ReadLine());
                    shelter.DeletePet(adoptSelection);
                    Console.WriteLine($"You adopted {pet.Name} the {pet.Species}");
                    break;

                case "13":
                    keepThinking = false;
                    break;
                }
            }
        }
Пример #3
0
        static void Main(string[] args)


        {
            VirtualPet virtualPet = new VirtualPet();
            Shelter    shelter    = new Shelter();



            Console.WriteLine("Welcome to Virtual Pets Place!");

            bool inMenu = true;

            do
            {
                Console.WriteLine("\nEnter Number of Menu Option");
                Console.WriteLine("\n1. Add Pet");
                Console.WriteLine("2. Feed Pet");
                Console.WriteLine("3. Play with Pet");
                Console.WriteLine("4. Take Pet to Doctor");
                Console.WriteLine("5. View Info of All Shelter Pets");
                Console.WriteLine("6. View Status of All Shelter Pets");
                Console.WriteLine("7. Feed All Pets");
                Console.WriteLine("8. Play with All Pets");
                Console.WriteLine("9. Maintain All Pets");
                Console.WriteLine("10. Adopt a Pet");
                Console.WriteLine("11. Exit Game");

                Console.WriteLine(); // <---This is here to add some space between the menu and the user's input

                string petMenuChoice = Console.ReadLine();


                switch (petMenuChoice)
                {
                case "1":
                    Console.WriteLine("\nType your pet's name  below:");
                    string name = Console.ReadLine();


                    Console.WriteLine("\nType your pet's species below:");
                    string species = Console.ReadLine();


                    Console.WriteLine("\nEnter A for an organic pet or B for a robotic pet");
                    string petType = Console.ReadLine().ToLower();

                    if (petType == "a")
                    {
                        VirtualPet organicPet = new OrganicPets();
                        organicPet.AddPet(name, species);
                        shelter.AddPetToShelter(organicPet);
                    }
                    else
                    {
                        VirtualPet roboticPet = new RoboticPets();
                        roboticPet.AddPet(name, species);
                        shelter.AddPetToShelter(roboticPet);
                    }
                    Console.WriteLine("\nYou've added a pet to the Shelter!");
                    break;



                case "2":

                    virtualPet = SelectPetMenu(shelter);
                    Console.WriteLine("\nYou've fed your pet!");
                    virtualPet.FeedPet();
                    break;

                case "3":

                    virtualPet = SelectPetMenu(shelter);
                    Console.WriteLine("\nThanks for playing with me!");
                    virtualPet.PlayPet();
                    break;

                case "4":

                    virtualPet = SelectPetMenu(shelter);
                    Console.WriteLine("\nYour pet's maintenance is A-Okay!");
                    virtualPet.MaintainPet();
                    break;

                case "5":
                    Console.WriteLine("\nChecking all pets info...");

                    //VirtualPet petChoiceInfo = SelectPetMenu(shelter);
                    shelter.DisplayInfoList();
                    break;

                case "6":
                    Console.WriteLine("\nChecking all pets status...");
                    shelter.DisplayStatusList();
                    break;

                case "7":
                    Console.WriteLine("\nYou've fed all your pets!");
                    shelter.FeedAllPets();
                    break;

                case "8":
                    Console.WriteLine("\nThanks for playing with all your pets!");
                    shelter.PlayAllPets();
                    break;

                case "9":
                    Console.WriteLine("\n The doctor says all your pets are A-Okay!");
                    shelter.DoctorAllPets();
                    break;

                case "10":
                    VirtualPet petChoice = SelectPetMenu(shelter);
                    shelter.RemovePet(petChoice);
                    break;


                case "11":
                    inMenu = false;
                    Console.WriteLine("\nSee yah!");
                    break;
                }
            }while (inMenu);
        }