public void AddOrganicPetToShelter(OrganicPet pet)
 {
     shelteredOrganicPets.Add(pet);
     allShelteredPets.Add(pet);
     Console.WriteLine($"You successfully added {pet.Name} to the shelter!");
     //move to OrganicPet.cs
 }
Ejemplo n.º 2
0
        public void CreateOrgPet()
        {
            Console.WriteLine("Create Organic Pet");
            OrganicPet temp = new OrganicPet(" ", " ", 1);

            temp.SpecifyPet();
            AddOrgPet(temp);
        }
Ejemplo n.º 3
0
        public void PetCreation()
        {
            Console.Clear();
            // Get pet type from user
            Console.WriteLine("Should your pet be Organic or Robotic? (type 'o' for Organic or 'r' for Robotic)");
            string type = Console.ReadLine();

            //Get name from user
            Console.Clear();
            Console.WriteLine("What should your pet's name be?");

            string Name = Console.ReadLine();

            Console.Clear();
            // Get species from user

            Console.WriteLine("What species should your pet be?");

            string Species = Console.ReadLine();

            Console.Clear();
            // Create Pet

            VirtualPets mypet;

            if (type == "o")
            {
                mypet = new OrganicPet(Name, Species);
            }
            else
            {
                mypet = new RoboticPet(Name, Species);
            }

            petsInShelter.Add(mypet);

            Console.WriteLine("Your awesome new pet " + Name + " is ready to play!");
            Console.WriteLine("Press 'Enter' to continue");
            Console.ReadLine();
            Console.Clear();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(130, 40);
            Console.BackgroundColor = ConsoleColor.DarkBlue; //Change Console background color

            //VirtualPet[] pet1 = new VirtualPet[2];
            Shelter allPets = new Shelter();

            //OrganicPet pet1 = new OrganicPet("Kitty", "Rob", 4);    //This may need to be removed
            bool gameContinues = true;

            //bool petExists = false;//probably remove

            OrganicPet.Kitty(10, 100); //Kitty(tabs, milliseconds);
            Console.WriteLine("Welcome to the Pet Shelter!");

            Console.BackgroundColor = ConsoleColor.Black; //Change console background color back to black

            /*
             * Shelter xxx = new Shelter();
             * Console.Clear();
             * xxx.DisplayAllPets();
             * Console.ReadLine();
             */

            do
            {
                Console.Write("\tType a LETTER to continue:       \n\n" +
                              "\tG - Give a Pet Away for Adoption\n" +
                              "\tA - Add a Pet            \n" +
                              "\tP - View Pets in Shelter \n" +
                              "\tI - View Instructions    \n" +
                              "\tE - Exit                 \n\n");

                //string userInput = Console.ReadLine().ToLower();
                string userInput = Console.ReadLine();
                if ((userInput.Length > 1) || !(char.IsLetter(userInput[0])))
                {
                    userInput = "x";
                }
                else
                {
                    userInput = userInput.ToLower();
                }

                Console.Clear();
                if (userInput.Equals("e"))
                {
                    Console.WriteLine("Good-bye. Come again soon.");
                    //Environment.Exit(0);
                    gameContinues = false;
                }
                else if (userInput.Equals("p"))//Display Shelter
                {
                    if (allPets.HowManyPetsInShelter() > 0)
                    {
                        Console.Clear();
                        int petChoice = 0;
                        do
                        {
                            Console.Clear();
                            allPets.DisplayAllPetsZZ();
                            Console.Write("\n\tChoose a pet (0 to Go Back): ");

                            //petChoice = Convert.ToInt32(Console.ReadLine());
                            string petChoiceString = Console.ReadLine();
                            if (char.IsNumber(petChoiceString[0]) && petChoiceString.Length == 1)
                            {
                                petChoice = Convert.ToInt32(petChoiceString);
                                //Console.WriteLine("petChoice: " + petChoice);
                            }
                            else
                            {
                                petChoice = -1;
                            }

                            if ((petChoice > 0) && (petChoice <= allPets.GetNumPets()))
                            {
                                bool continueInteracting = true;

                                do
                                {
                                    Console.Clear();
                                    allPets.DisplayShelterPetInfo(petChoice);
                                    continueInteracting = allPets.DisplayShelterPetInteractions(petChoice);
                                    if (continueInteracting)
                                    {
                                        allPets.TimePasses();
                                    }
                                    allPets.CheckForDeath();
                                    if (petChoice > allPets.HowManyPetsInShelter())
                                    {
                                        continueInteracting = false;
                                    }
                                } while (continueInteracting);
                            }
                            else
                            {
                                //invalid choice
                                Console.WriteLine("Please choose a valid pet");
                            }
                        } while (petChoice != 0);
                        //Console.ReadLine()
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("The Shelter is EMPTY! (Hint: Add a Pet)");
                        Console.WriteLine("...Press any key to continue");
                        Console.ReadKey();
                    }
                }
                else if (userInput.Equals("a"))
                {
                    int petType = 0;
                    do
                    {
                        Console.Clear();
                        Console.WriteLine("Add a Pet...");
                        Console.WriteLine("Which type of Pet?");
                        Console.WriteLine("\t1. Organic");
                        Console.WriteLine("\t2. Robotic");

                        petType = 0;
                        string petChoiceString = Console.ReadLine();
                        if (char.IsNumber(petChoiceString[0]) && petChoiceString.Length == 1)
                        {
                            petType = Convert.ToInt32(petChoiceString);
                            //Console.WriteLine("petChoice: " + petChoice);
                        }
                        else
                        {
                            petType = -1;
                        }
                        switch (petType)
                        {
                        case 1:
                            allPets.CreateOrgPet();
                            break;

                        case 2:
                            allPets.CreateRoboPet();
                            break;

                        default:
                            Console.WriteLine("Choose Organic or Robotic");
                            break;
                        }
                    } while (!(petType >= 1 && petType <= 2));
                }
                else if (userInput.Equals("i"))
                {
                    Console.Clear();
                    displayInstructions();
                    Console.WriteLine("...Press any key to continue");
                    Console.ReadKey();
                }
                else if (userInput.Equals("g"))
                {
                    if (allPets.HowManyPetsInShelter() > 0)
                    {
                        Console.Clear();
                        int  petChoice     = 0;
                        bool petWasRemoved = false;
                        do
                        {
                            allPets.DisplayAllPetsZ();
                            Console.WriteLine("Which Pet found a Permanent Home?");
                            Console.Write("\n\tChoose a pet: ");

                            //petChoice = Convert.ToInt32(Console.ReadLine());
                            string petChoiceString = Console.ReadLine();
                            if (char.IsNumber(petChoiceString[0]) && petChoiceString.Length == 1)
                            {
                                petChoice = Convert.ToInt32(petChoiceString);
                                //Console.WriteLine("petChoice: " + petChoice);
                            }
                            else
                            {
                                petChoice = -1;
                            }

                            if ((petChoice > 0) && (petChoice <= allPets.GetNumPets()))
                            {
                                allPets.RemoveAPet(petChoice);
                                petWasRemoved = true;
                            }
                            else
                            {
                                //invalid choice
                                Console.WriteLine("Please choose a valid pet");
                            }
                        } while (petChoice != 0 && !petWasRemoved);
                        //Console.ReadLine()
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("The Shelter is EMPTY! (Hint: Add a Pet)");
                        Console.WriteLine("...Press any key to continue");
                        Console.ReadKey();
                    }
                }
                else
                {
                    Console.WriteLine("Please choose a valid option!");
                    Console.WriteLine("...Press any key to continue.");
                    Console.ReadKey();
                    Console.Clear();
                }
                Console.Clear();
            } while (gameContinues);
        }
Ejemplo n.º 5
0
 public void RemoveOrgPet(OrganicPet temp)
 {
     OrgPets.Remove(temp);
     NumPets--;
 }
Ejemplo n.º 6
0
 public void AddOrgPet(OrganicPet aPet)
 {
     OrgPets.Add(aPet);
     NumPets++;
 }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            OrganicPet        newOrganicPet = new OrganicPet();
            RoboticPet        newRoboticPet = new RoboticPet();
            VirtualPetShelter ourPetShelter = new VirtualPetShelter();
            bool playing = true;
            int  time    = 1;

            Console.WriteLine("Welcome to VirtualPets! Let's get started by adding your first pet to the shelter.");
            bool validOption = false;

            while (validOption == false)
            {
                Console.WriteLine("What is your pet?: 1.Organic 2.Robotic");
                string userInput = (Console.ReadLine());
                if (userInput == "1")
                {
                    newOrganicPet.CreatePet();
                    ourPetShelter.AddOrganicPetToShelter(newOrganicPet);
                    validOption = true;
                }
                else if (userInput == "2")
                {
                    newRoboticPet.CreatePet();
                    ourPetShelter.AddRoboticPetToShelter(newRoboticPet);
                    validOption = true;
                }
                else
                {
                    Console.WriteLine("Please enter '1' or '2'.");
                }
            }

            do
            {
                Console.WriteLine("\nMain Menu");
                Console.WriteLine("1. Add Pet to Shelter");
                Console.WriteLine("2. Select Pet");
                Console.WriteLine("3. Check Info (Name and Species) of Pet");
                Console.WriteLine("4. Check Status of your Pets");
                Console.WriteLine("5. Feed Your Pet(s)");
                Console.WriteLine("6. Take Pet(s) To Doctor");
                Console.WriteLine("7. Play With Pet(s)");
                Console.WriteLine("8. Adopt a Pet (Remove from list)");
                Console.WriteLine("9. Exit");
                Console.Write("\nPlease enter a number 1 through 9: ");

                if (time % 5 == 0)
                {
                    foreach (VirtualPet pet in ourPetShelter.allShelteredPets)
                    {
                        pet.TimeLapse();
                    }
                }

                string userChoice = Console.ReadLine();
                switch (userChoice)
                {
                case "1":
                {
                    Console.WriteLine("What is your pet?: 1.Organic 2.Robotic");
                    string newUserInput = Console.ReadLine();
                    if (newUserInput == "1")
                    {
                        newOrganicPet = new OrganicPet();
                        newOrganicPet.CreatePet();
                        ourPetShelter.AddOrganicPetToShelter(newOrganicPet);
                    }
                    else if (newUserInput == "2")
                    {
                        newRoboticPet = new RoboticPet();
                        newRoboticPet.CreatePet();
                        ourPetShelter.AddRoboticPetToShelter(newRoboticPet);
                    }
                    else
                    {
                        Console.WriteLine("You didn't enter a valid number.");
                    }
                    break;
                }

                case "2":
                {
                    Console.WriteLine("Which pet list do you wish to see?: 1.Organic 2.Robotic");
                    string newUserInput = Console.ReadLine();
                    if (newUserInput == "1")
                    {
                        ourPetShelter.ShowOrganicShelteredPetsInfo();
                        newOrganicPet = ourPetShelter.ChoosePetFromOrganicList();
                        Console.WriteLine($"You've selected {newOrganicPet.Name}. Returning to Main Menu.");
                    }
                    else if (newUserInput == "2")
                    {
                        ourPetShelter.ShowRoboticShelteredPetsInfo();
                        newRoboticPet = ourPetShelter.ChoosePetFromRoboticList();
                        Console.WriteLine($"You've selected {newRoboticPet.Name}. Returning to Main Menu.");
                    }
                    else
                    {
                        Console.WriteLine("You did not enter '1' or '2'. Returning to main menu.");
                    }
                    break;
                }

                case "3":
                {
                    Console.WriteLine("Which pet list do you wish to see?: 1.Organic 2.Robotic");
                    string newUserInput = Console.ReadLine();
                    if (newUserInput == "1")
                    {
                        ourPetShelter.ShowOrganicShelteredPetsInfo();
                    }
                    else if (newUserInput == "2")
                    {
                        ourPetShelter.ShowRoboticShelteredPetsInfo();
                    }
                    else
                    {
                        Console.WriteLine("You did not enter '1' or '2'. Returning to main menu.");
                    }
                    break;
                }

                case "4":
                {
                    Console.WriteLine("Which pet list do you wish to see?: 1.Organic 2.Robotic");
                    string newUserInput = Console.ReadLine();
                    if (newUserInput == "1")
                    {
                        ourPetShelter.ShowShelteredOrganicPetsStatus();
                    }
                    else if (newUserInput == "2")
                    {
                        ourPetShelter.ShowShelteredRoboticPetsStatus();
                    }
                    else
                    {
                        Console.WriteLine("You did not enter '1' or '2'. Returning to main menu.");
                    }
                    break;
                }

                case "5":
                {
                    Console.WriteLine($"Press '1' to feed {newOrganicPet.Name} or '2' to feed {newRoboticPet.Name}. \nPress '3' to feed/oil all pets. \nPress any other key to return to main menu.");
                    string mealChoice = Console.ReadLine();
                    switch (mealChoice)
                    {
                    case "1":
                    {
                        newOrganicPet.FeedPetDinner();
                        Console.WriteLine($"You fed {newOrganicPet.Name} dinner. Your pet is now full.");
                        time++;
                        break;
                    }

                    case "2":
                    {
                        newRoboticPet.FeedPetDinner();
                        Console.WriteLine($"You oiled {newRoboticPet.Name}. No more squeaks!");
                        time++;
                        break;
                    }

                    case "3":
                    {
                        ourPetShelter.FeedAllPetsDinner();
                        Console.WriteLine("You have fed and/or oiled all the pets in the shelter!");
                        time++;
                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Returning to main menu.");
                        break;
                    }
                    }
                    break;
                }

                case "6":
                {
                    Console.WriteLine($"Press '1' to take {newOrganicPet.Name} to the doctor or '2' to take {newRoboticPet.Name} to the mechanic. \nPress '3' to take all pets to the doctor/mechanic.\nPress any other key to return to the main menu.");
                    string doctorChoice = Console.ReadLine();
                    switch (doctorChoice)
                    {
                    case "1":
                    {
                        newOrganicPet.TakePetToDoctor();
                        Console.WriteLine($"You took {newOrganicPet.Name} to the doctor. It is now healthy!");
                        time++;
                        break;
                    }

                    case "2":
                    {
                        newRoboticPet.TakePetToDoctor();
                        Console.WriteLine($"You took {newRoboticPet.Name} to the mechanic. It is now functioning properly!");
                        time++;
                        break;
                    }

                    case "3":
                    {
                        ourPetShelter.TakeAllPetsToDoctor();
                        Console.WriteLine("You took all your pets to the doctor/mechanic. All of them are now healthy!");
                        time++;
                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Returning to main menu.");
                        break;
                    }
                    }
                    break;
                }

                case "7":
                {
                    Console.WriteLine($"Press '1' to play with {newOrganicPet.Name} or press '2' to play with {newRoboticPet.Name}. \nPress '3' to play with all of your pets. \nPress any other key to return to the main menu.");
                    string playChoice = Console.ReadLine();
                    switch (playChoice)
                    {
                    case "1":
                    {
                        newOrganicPet.PlayWithPet();
                        Console.WriteLine($"You have played with {newOrganicPet.Name}! It's less bored and healthier, but is more hungry now!");
                        time++;
                        break;
                    }

                    case "2":
                    {
                        newRoboticPet.PlayWithPet();
                        Console.WriteLine($"You have played with {newRoboticPet.Name}! It's less bored, but now needs some oil and maintenance!");
                        time++;
                        break;
                    }

                    case "3":
                    {
                        ourPetShelter.PlayWithAllPets();
                        Console.WriteLine("You have played with all pets in the shelter! Their statuses have changed.");
                        time++;
                        break;
                    }
                    }
                    break;
                }

                case "8":
                {
                    ourPetShelter.AdoptPet();
                    break;
                }

                case "9":
                {
                    playing = false;
                    Console.WriteLine("Goodbye!");
                    break;
                }

                default:
                {
                    Console.WriteLine("Please enter a valid number.");
                    break;
                }
                }
            } while (playing);
        }