private void handleItem(int option) { try { IPetItem item = player.Take(option); switch (optionSelected) { case PlayerAction.Feed: pet1.Feed(item); break; case PlayerAction.Play: pet1.Play(item); break; case PlayerAction.Medicate: pet1.Medicate(item); break; } } catch (ArgumentOutOfRangeException e) { Console.WriteLine("Invalid Option"); } appState = AppState.Running; }
static void Main(string[] args) { Pet myPet = new Pet(); Shelter myShelter = new Shelter(); Organic myOrganic = new Organic(); Robot myRobot = new Robot(); Console.WriteLine("Hello! Welcome to Virtual Pet Shelter"); bool keepPlaying = true; while (keepPlaying) { Console.WriteLine("1. Create Robot Pet"); Console.WriteLine("2. Create Organic Pet"); Console.WriteLine("3. Check On All Pets"); Console.WriteLine("4. Feed or Oil All Pets"); Console.WriteLine("5. Select a Pet to Feed or Oil."); Console.WriteLine("6. Play with All Pets"); Console.WriteLine("7. Select a Pet to Play with."); Console.WriteLine("8. Take All Pets to the Vet or Mechanic"); Console.WriteLine("9. Select a Pet to take to the Vet or Mechanic."); Console.WriteLine("10. Select a Pet to be Adopted from the Shelter."); Console.WriteLine("11. Exit Game"); string menuChoice = Console.ReadLine(); int petBoredom = myPet.GetBoredom(); int petHealth = myPet.GetHealth(); int petHunger = myPet.GetHunger(); int robotPerformance = myRobot.GetPerformance(); int robotOil = myRobot.GetOil(); switch (menuChoice) { case "1": myShelter.AddPet(myRobot); Console.WriteLine("What Species is Your Robot Pet? "); myRobot.SetSpecies(Console.ReadLine()); Console.WriteLine("Please Enter the Name of Your Robot " + myRobot.Species + ": "); myRobot.SetName(Console.ReadLine()); break; case "2": myShelter.AddPet(myOrganic); Console.WriteLine("What Species is Your Organic Pet? "); myOrganic.SetSpecies(Console.ReadLine()); Console.WriteLine("Please Enter the Name of Your Organic " + myOrganic.Species + ": "); myOrganic.SetName(Console.ReadLine()); break; case "3": foreach (Pet pet in myShelter.ListofPets) { Console.WriteLine("The Current Boredom level of " + pet.Name + " is " + petBoredom); if (pet == myOrganic) { Console.WriteLine("The Current Health Level of " + pet.Name + " is " + petHealth); Console.WriteLine("The Current Hunger Level of " + pet.Name + " is " + petHunger); } else if (pet == myRobot) { Console.WriteLine("The Current Oil Level of " + pet.Name + " is " + robotOil); Console.WriteLine("The Current Performance Level of " + pet.Name + " is " + robotPerformance); } } break; case "4": foreach (Pet pet in myShelter.ListofPets) { if (pet == myOrganic) { myPet.Feed(); Console.WriteLine("You Fed " + pet.Name); } else if (pet == myRobot) { myRobot.GetOil(); Console.WriteLine("You gave oil to " + pet.Name); } } break; case "5": myPet = myShelter.SelectPet(); if (myPet == myOrganic) { myPet.Feed(); Console.WriteLine("You Fed " + myPet.Name); } else if (myPet == myRobot) { myRobot.GetOil(); Console.WriteLine("You gave oil to " + myPet.Name); } break; case "6": foreach (Pet pet in myShelter.ListofPets) { pet.Play(); Console.WriteLine("You played with " + pet.Name); } break; case "7": myPet = myShelter.SelectPet(); myPet.Play(); Console.WriteLine("You played with " + myPet.Name); break; case "8": foreach (Pet pet in myShelter.ListofPets) { if (pet == myOrganic) { pet.SeeDoctor(); Console.WriteLine("You took " + pet.Name + " to the vet!"); } else if (pet == myRobot) { myRobot.SeeMechanic(); Console.WriteLine("You took " + pet.Name + " to the mechanic!"); } } break; case "9": myPet = myShelter.SelectPet(); if (myPet == myOrganic) { myPet.SeeDoctor(); Console.WriteLine("You took " + myPet.Name + " to the vet!"); } else if (myPet == myRobot) { myRobot.SeeMechanic(); Console.WriteLine("You took " + myPet.Name + " to the mechanic!"); } break; case "10": myShelter.AdoptPet(); Console.WriteLine("That pet has been adopted!"); break; case "11": Console.WriteLine("Thank's for Playing!"); keepPlaying = false; break; default: Console.WriteLine("Invalid Entry"); break; } myPet.Tick(); Console.WriteLine("Press Any Key to Continue"); Console.ReadKey(); Console.Clear(); } }
static void Main(string[] args) { Pet Pet = new Pet(); Console.WriteLine("Hello! Welcome to Virtual Pets.\n"); Console.WriteLine("What's the name of your new pet?"); Pet.SetName(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("What's the species of your new pet?"); Pet.SetSpecies(Console.ReadLine()); Console.WriteLine(); Console.WriteLine($"\n{Pet.GetName()} the {Pet.GetSpecies()} is here!"); bool gamePlay = true; do { ; Console.WriteLine($"Hunger is {Pet.GetHunger()}."); Console.WriteLine($"Boredom is {Pet.GetBoredom()}."); Console.WriteLine($"Health is {Pet.GetHealth()}."); Pet.Tick(); Console.WriteLine("\nWhat would you like to do with your pet?\n"); Console.WriteLine("Play with my pet - press 1"); Console.WriteLine("\nFeed my pet - press 2"); Console.WriteLine("\nTake my pet to the doctor - press 3"); Console.WriteLine("\nQuit - press 4"); string inPlay = Console.ReadLine(); Console.Clear(); switch (inPlay) { case "1": Pet.Play(); break; case "2": Pet.Feed(); break; case "3": Pet.SeeDoctor(); break; case "4": Console.WriteLine("Thanks for playing!"); gamePlay = false; break; default: Console.WriteLine("Enter a number."); break; } } while (gamePlay); }
static void Main(string[] args) { Console.WriteLine("Hello! Welcome to Virtual Pets shelter"); Shelter shelter = new Shelter(); Pet pet = new Pet(); Random random = new Random(); bool keepPlaying = true; bool returnToOffice = false; string playerChoice; while (keepPlaying) { Console.WriteLine("Welcome to " + shelter.Name + " Animal Shelter."); Console.WriteLine("What would you like to do?"); Console.WriteLine("1. Name/Re-Name Shelter"); Console.WriteLine("2. Add Organic Pet"); Console.WriteLine("3. Add Robotic Pet"); Console.WriteLine("4. Adopt a Pet"); Console.WriteLine("5. List Pets in Shelter"); Console.WriteLine("6. Enter the Kennel"); Console.WriteLine("7. Quit"); playerChoice = Console.ReadLine(); Console.Clear(); switch (playerChoice) { case "1": Console.WriteLine("What do you want to name your Animal Shelter?"); shelter.Name = Console.ReadLine(); break; case "2": Console.WriteLine("What is the name of your pet?"); string nameOfPet = Console.ReadLine(); Console.WriteLine("What is the species of your pet?"); string speciesOfPet = Console.ReadLine(); Organic organic = new Organic(nameOfPet, speciesOfPet); shelter.AddPet(organic); break; case "3": Console.WriteLine("What is the name of your pet?"); nameOfPet = Console.ReadLine(); Console.WriteLine("What is the species of your pet?"); speciesOfPet = Console.ReadLine(); Robotic robotic = new Robotic(nameOfPet, speciesOfPet); shelter.AddPet(robotic); break; case "4": Console.WriteLine("Which pet would you like to adopt?"); string userPet = Console.ReadLine(); int userPetIndex = shelter.SelectPet(userPet); if (userPetIndex == -1) { Console.WriteLine("That pet isn't listed in our records."); } else { Console.WriteLine(shelter.ListofPets[userPetIndex].Name + " has been adopted."); shelter.RemovePet(userPetIndex); } Console.ReadKey(); break; case "5": for (int i = 0; i < shelter.ListofPets.Count; i++) { if (shelter.ListofPets[i].IsOrganic == true) { Console.WriteLine(shelter.ListofPets[i].Name + " the organic " + shelter.ListofPets[i].Species); } else { Console.WriteLine(shelter.ListofPets[i].Name + " the robotic " + shelter.ListofPets[i].Species); } } Console.ReadKey(); break; case "6": returnToOffice = false; while (returnToOffice == false) { Kennel(); } break; case "7": keepPlaying = false; break; default: Console.WriteLine("Please enter a valid number."); break; } Console.Clear(); } void Kennel() { Console.WriteLine("What would you like to do?"); Console.WriteLine("1. Feed all organic pets"); Console.WriteLine("2. Oil all robotic pets"); Console.WriteLine("3. Play with all pets"); Console.WriteLine("4. Take all organic pets to Doctor"); Console.WriteLine("5. Perform maintenence on all Robotic Pets"); Console.WriteLine("6. Interact with a single pet"); Console.WriteLine("7. Check all pet statuses"); Console.WriteLine("8. Return to Office"); playerChoice = Console.ReadLine(); switch (playerChoice) { case "1": for (int i = 0; i < shelter.ListofPets.Count; i++) { if (shelter.ListofPets[i].IsOrganic == true) { shelter.ListofPets[i].Feed(); } } Console.WriteLine("You fed the pets!"); break; case "2": for (int i = 0; i < shelter.ListofPets.Count; i++) { if (shelter.ListofPets[i].IsOrganic == false) { shelter.ListofPets[i].GiveOil(); } } Console.WriteLine("You oiled the pets!"); break; case "3": for (int i = 0; i < shelter.ListofPets.Count; i++) { shelter.ListofPets[i].Play(); } Console.WriteLine("You played with the pets!"); break; case "4": for (int i = 0; i < shelter.ListofPets.Count; i++) { if (shelter.ListofPets[i].IsOrganic == true) { shelter.ListofPets[i].SeeDoctor(); } } Console.WriteLine("You took the pets to the doctor!"); break; case "5": for (int i = 0; i < shelter.ListofPets.Count; i++) { if (shelter.ListofPets[i].IsOrganic == false) { shelter.ListofPets[i].PerformMaintenance(); } } Console.WriteLine("You repaired the pets!"); break; case "6": Console.WriteLine("What pet do you want to interact with?"); string userPet = Console.ReadLine(); int userPetIndex = shelter.SelectPet(userPet); SinglePet(userPetIndex); break; case "7": for (int i = 0; i < shelter.ListofPets.Count; i++) { if (shelter.ListofPets[i].IsOrganic == true) { Console.WriteLine($"{shelter.ListofPets[i].Name} the organic {shelter.ListofPets[i].Species}- Hunger: {shelter.ListofPets[i].Hunger} " + $"Health: {shelter.ListofPets[i].Health} Boredom: {shelter.ListofPets[i].Boredom}"); } else if (shelter.ListofPets[i].IsOrganic == false) { Console.WriteLine($"{shelter.ListofPets[i].Name} the robotic {shelter.ListofPets[i].Species}- Oil: {shelter.ListofPets[i].Oil} " + $"Performance: {shelter.ListofPets[i].Performance} Boredom: {shelter.ListofPets[i].Boredom}"); } } break; case "8": Console.WriteLine("Thank you for taking care of the pets."); returnToOffice = true; break; default: Console.WriteLine("Please select a valid option"); break; } shelter.Tick(); Console.ReadKey(); Console.Clear(); } void SinglePet(int index) { bool returnToKennel = false; while (returnToKennel == false) { Console.Clear(); Console.WriteLine("What would you like to do?"); Console.WriteLine("1. Name/Rename " + shelter.ListofPets[index].Name); Console.WriteLine("2. Change Species of " + shelter.ListofPets[index].Name); if (shelter.ListofPets[index].IsOrganic == true) { Console.WriteLine("3. Feed " + shelter.ListofPets[index].Name); Console.WriteLine("4. Play with " + shelter.ListofPets[index].Name); Console.WriteLine("5. Take " + shelter.ListofPets[index].Name + " to Doctor"); } else { Console.WriteLine("3. Oil " + shelter.ListofPets[index].Name); Console.WriteLine("4. Play with " + shelter.ListofPets[index].Name); Console.WriteLine("5. Perform Maintenance on " + shelter.ListofPets[index].Name); } Console.WriteLine("6. Check " + shelter.ListofPets[index].Name + "'s status"); Console.WriteLine("7. Return to Kennel"); playerChoice = Console.ReadLine(); switch (playerChoice) { case "1": Console.WriteLine("What would you like you to rename your pet?"); shelter.ListofPets[index].Name = Console.ReadLine(); Console.WriteLine("You named your pet " + shelter.ListofPets[index].Name); break; case "2": Console.WriteLine("What species do you want " + shelter.ListofPets[index].Name + " to be?"); shelter.ListofPets[index].Species = Console.ReadLine(); Console.WriteLine(shelter.ListofPets[index].Name + " is a " + shelter.ListofPets[index].Species); break; case "3": if (shelter.ListofPets[index].IsOrganic == true) { Console.WriteLine("What would you like to feed " + shelter.ListofPets[index].Name + "?"); string food = Console.ReadLine(); if (random.Next(1, 100) < shelter.ListofPets[index].Boredom) { Console.WriteLine(shelter.ListofPets[index].Name + " doesnt't want your food."); } else { pet.Feed(food.ToLower()); Console.WriteLine("You fed " + shelter.ListofPets[index].Name); Console.WriteLine(shelter.ListofPets[index].Name + "s hunger level is " + shelter.ListofPets[index].Hunger); } } else { Console.WriteLine("You oiled " + shelter.ListofPets[index].Name); shelter.ListofPets[index].GiveOil(); Console.WriteLine(shelter.ListofPets[index].Name + "'s oil level is " + shelter.ListofPets[index].Oil); } break; case "4": pet.Play(); Console.WriteLine("You played with " + shelter.ListofPets[index].Name); Console.WriteLine(shelter.ListofPets[index].Name + "s boredom level is " + shelter.ListofPets[index].Boredom); if (shelter.ListofPets[index].IsOrganic == true) { Console.WriteLine(shelter.ListofPets[index].Name + "s health level is " + shelter.ListofPets[index].Health); Console.WriteLine(shelter.ListofPets[index].Name + "s hunger level is " + shelter.ListofPets[index].Hunger); } else { Console.WriteLine(shelter.ListofPets[index].Name + "s oil level is " + shelter.ListofPets[index].Oil); Console.WriteLine(shelter.ListofPets[index].Name + "s performance level is " + shelter.ListofPets[index].Performance); } break; case "5": if (shelter.ListofPets[index].IsOrganic == true) { pet.SeeDoctor(); Console.WriteLine("You took " + shelter.ListofPets[index].Name + " to the doctor."); Console.WriteLine(shelter.ListofPets[index].Name + "'s health is now " + shelter.ListofPets[index].Health); } else { pet.PerformMaintenance(); Console.WriteLine("You performed maintenance on " + shelter.ListofPets[index].Name); Console.WriteLine(shelter.ListofPets[index].Name + "'s oil level is now " + shelter.ListofPets[index].Oil); Console.WriteLine(shelter.ListofPets[index].Name + "'s performance level is now " + shelter.ListofPets[index].Performance); } break; case "6": Console.WriteLine(shelter.ListofPets[index].Name); Console.WriteLine(shelter.ListofPets[index].Species); if (shelter.ListofPets[index].IsOrganic == true) { Console.WriteLine("Hunger: " + shelter.ListofPets[index].Hunger); Console.WriteLine("Health: " + shelter.ListofPets[index].Health); } else { Console.WriteLine("Oil: " + shelter.ListofPets[index].Oil); Console.WriteLine("Performance: " + shelter.ListofPets[index].Performance); } Console.WriteLine("Boredom: " + shelter.ListofPets[index].Boredom); break; case "7": Console.WriteLine("Thank you for playing with " + shelter.ListofPets[index].Name + "!"); returnToKennel = true; break; default: Console.WriteLine("Please enter a valid entry"); break; } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Console.Clear(); shelter.ListofPets[index].Tick(); //if (shelter.ListofPets[index].Health <= 0) //{ // Console.WriteLine(shelter.ListofPets[index].Name.ToUpper() + " HAS DIED!"); // returnToKennel = true; //} //else if (shelter.ListofPets[index].Performance <= 0) //{ // Console.WriteLine(shelter.ListofPets[index].Name.ToUpper() + " HAS BROKEN!"); // returnToKennel = true; //} //else if (shelter.ListofPets[index].Hunger > 100) //{ // shelter.ListofPets[index].Hunger -= 10; // Console.WriteLine(shelter.ListofPets[index].Name + " got hungry and found some food on their own."); //} //else if (shelter.ListofPets[index].Oil < 0) //{ // shelter.ListofPets[index].Oil += 10; // Console.WriteLine(shelter.ListofPets[index].Name + " got squeaky and found some oil on it's own."); //} //else if (shelter.ListofPets[index].Boredom > 100) //{ // shelter.ListofPets[index].Boredom -= 10; // Console.WriteLine(shelter.ListofPets[index].Name + " got bored and found a toy to play with."); //} //if (shelter.ListofPets[index].Health <= 0) //{ // Console.WriteLine(@"(\ _ /)"); // Console.WriteLine("(X - X)"); // Console.WriteLine("c(\")(\")"); // shelter.RemovePet(index); //} //else if (shelter.ListofPets[index].Performance <= 0) //{ // Console.WriteLine(@"(\ _ /)"); // Console.WriteLine("(X - X)"); // Console.WriteLine("c(\")(\")"); // shelter.RemovePet(index); //} //else if (shelter.ListofPets[index].Health < 20) //{ // Console.WriteLine(@"(\ _ /)"); // Console.WriteLine("(0 ~ 0)"); // Console.WriteLine("c(\")(\")"); //} //else if (shelter.ListofPets[index].Performance <20) //{ // Console.WriteLine(@"(\ _ /)"); // Console.WriteLine("(0 ~ 0)"); // Console.WriteLine("c(\")(\")"); //} //else if (shelter.ListofPets[index].Boredom > 80) //{ // Console.WriteLine(@"(\ _ /)"); // Console.WriteLine("(- X -)"); // Console.WriteLine("c(\")(\")"); //} //else if (shelter.ListofPets[index].Hunger > 80) //{ // Console.WriteLine(@"(\ _ /)"); // Console.WriteLine("(' O ')"); // Console.WriteLine("c(\")(\")"); //} //else if (shelter.ListofPets[index].Oil < 20) //{ // Console.WriteLine(@"(\ _ /)"); // Console.WriteLine("(' O ')"); // Console.WriteLine("c(\")(\")"); //} //else //{ // Console.WriteLine(@"(\ _ /)"); // Console.WriteLine("(' X ')"); // Console.WriteLine("c(\")(\")"); //} //Console.ReadKey(); } } }
static void Main(string[] args) { Pet newPet = new Pet(); PetShelter petShelter = new PetShelter(); RoboticPet roboticPet = new RoboticPet(); List <Pet> listOfPets = petShelter.GetPetList(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("Hello! Welcome to Virtual Pets"); Console.ResetColor(); newPet.CreatePet(); petShelter.AddPetToShelter(newPet); bool continuePlayingWithPet = true; do { petShelter.AllPetsTick(); petShelter.ShowAllPetStatus(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\nWhat would you like to do?"); Console.ResetColor(); Console.WriteLine($"1. Feed {newPet.GetName()}"); Console.WriteLine($"2. Play with {newPet.GetName()}"); Console.WriteLine($"3. Take {newPet.GetName()} to doctor or for maintenance"); Console.WriteLine("4. Add pet"); Console.WriteLine("5. Add RoboPet"); Console.WriteLine("6. Feed all pets"); Console.WriteLine("7. Take all pets to doctor or for maintenance"); Console.WriteLine("8. Play with all pets"); Console.WriteLine("9. Select specific pet"); Console.WriteLine("10. Adopt pet"); Console.WriteLine("11. Exit virtual pet"); string userInput = Console.ReadLine(); Console.Clear(); switch (userInput) { case "1": { newPet.Feed(); break; } case "2": { newPet.Play(); Console.WriteLine("You've played with your Pet"); break; } case "3": { newPet.CareForPet(); break; } case "4": { newPet = new Pet(); newPet.CreatePet(); petShelter.AddPetToShelter(newPet); break; } case "5": { roboticPet = new RoboticPet(); roboticPet.CreatePet(); petShelter.AddPetToShelter(roboticPet); break; } case "6": { petShelter.FeedAllPets(); break; } case "7": { petShelter.AllPetsSeeDoctor(); break; } case "8": { petShelter.AllPetsPlay(); break; } case "9": { petShelter.ShowPetNames(); Console.WriteLine("What pet do you want to select?"); int selectNewPet = Convert.ToInt32(Console.ReadLine()); newPet = petShelter.SelectPetFromShelter(selectNewPet - 1); break; } case "10": { petShelter.ShowPetNames(); Console.WriteLine("What pet do you want to adopt?"); int selectNewPet = Convert.ToInt32(Console.ReadLine()); newPet = petShelter.SelectPetFromShelter(selectNewPet - 1); petShelter.AdoptPetFromShelter(newPet); break; } case "11": { Console.WriteLine("Thanks for playing Virtual Pet"); continuePlayingWithPet = false; break; } } } while (continuePlayingWithPet); }
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); }
public static void Main(string[] args) { bool stillPlaying = true; Pet newPet = new Pet(); RoboticPet roboticPet = new RoboticPet(); OrganicPet organicPet = new OrganicPet(); PetShelter myShelter = new PetShelter(); while (stillPlaying) { myShelter.TickOnAllPets(); Console.WriteLine("\n\tHello! Welcome to Virtual Pets"); Console.WriteLine("\n"); Console.WriteLine("\t1. View list of pets."); Console.WriteLine("\t2. Bringing in a new pet?"); Console.WriteLine("\t3. Select a certain pet to interact with."); Console.WriteLine("\t4. Feed your pet(s)."); Console.WriteLine("\t5. Give your pet(s) water."); Console.WriteLine("\t6. Your pet(s) bored, let's play."); Console.WriteLine("\t7. Time for a checkup with the vet."); Console.WriteLine("\t8. Adopt a pet!\n"); Console.WriteLine($"\n\tYou are currently interacting with " + newPet.Name); Console.WriteLine("\n\t Press 'Q' to Exit game."); Console.WriteLine("\tPress enter to return to the Main Menu\n"); string userChoice = Console.ReadLine().ToLower(); Console.Clear(); switch (userChoice) { case "1": myShelter.PrintAllPetsList(); Console.Clear(); break; case "2": Console.WriteLine("\tEnter 1' [Organic Pet] or '2' [Robotic Pet]."); string petChoice = Console.ReadLine(); switch (petChoice) { case "1": myShelter.PrintAllPetsList(); organicPet = new OrganicPet(); organicPet.CreatePet(); myShelter.AddPet(organicPet); break; case "2": myShelter.PrintAllPetsList(); roboticPet = new RoboticPet(); roboticPet.CreatePet(); myShelter.AddPet(roboticPet); break; default: break; } break; case "3": myShelter.PrintAllPetsList(); Console.WriteLine("Select pet by number to view."); newPet = myShelter.FindAnimalByIndex(); break; case "4": Console.WriteLine("\tEnter 1' [To feed one pet] or '2' [Feed all pets]."); string feedChoice = Console.ReadLine(); switch (feedChoice) { case "1": newPet.Feed(); Console.WriteLine($"\tYou fed {newPet.Name}"); break; case "2": myShelter.FeedAll(); Console.WriteLine($"\tYou fed all the animals in the shelter!"); break; default: break; } break; case "5": Console.WriteLine("\tPress '1' [To quench one pet's thirst] or press '2' [For all pets]."); string thirstChoice = Console.ReadLine(); switch (thirstChoice) { case "1": newPet.GiveWater(); Console.WriteLine($"\tYou gave {newPet.Name} somthing to drink"); break; case "2": myShelter.WaterAll(); Console.WriteLine($"\tYou gave all your animals something to drink."); break; default: break; } break; case "6": Console.WriteLine("\tPress '1'[Play with one pet] or press '2' [Play with all pets]."); string playChoice = Console.ReadLine(); switch (playChoice) { case "1": newPet.Play(); Console.WriteLine($"\tYou played with {newPet.Name}"); break; case "2": myShelter.PlayWithAll(); Console.WriteLine($"\tYou played with all the animals."); break; default: break; } break; case "7": Console.WriteLine("\tPress '1' [To take one pet] or press '2' [To take all pets]."); string healthChoice = Console.ReadLine(); Console.Clear(); switch (healthChoice) { case "1": newPet.SeeDoctor(); Console.WriteLine($"{ newPet.Name} is feeling much better!"); break; case "2": myShelter.SeeDoctorAll(); break; default: break; } break; case "8": myShelter.PrintAllPetsList(); Console.WriteLine("\n\tWho do you want to adopt?"); Pet petToRemove = myShelter.FindAnimalByIndex(); myShelter.AdoptPet(petToRemove); Console.WriteLine(newPet.Name + $"said yes!! You'll make a great pet parent!"); break; case "q": Console.ReadLine().ToLower(); break; default: break; } } }
static bool quit = false; // Quit is currently false static void Main(string[] args) { do { SoundPlayer startLine = new SoundPlayer(@"C:\\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\unused.wav"); { startLine.PlaySync(); } //This plays the intro sound! Console.WriteLine("Hello!"); Console.WriteLine("You are now taking the first step to the amazing world of pet ownership"); Console.WriteLine("We have analyzed your dreams and figured out your dream pet."); Console.WriteLine("You will be meeting him today!"); Console.WriteLine("press enter to continue"); Console.ReadKey(); Console.WriteLine("(o___o) !!! "); Console.WriteLine("There he is!! Any idea what you're going to name him?"); Console.WriteLine("Type in a name!"); userPetname = Console.ReadLine(); //Give the pet a name! :D Console.WriteLine("Awesome! " + userPetname + " seems happy to see you!!!"); Console.WriteLine("press enter to continue"); Console.ReadKey(); Console.WriteLine("(^__^) yeey!!! "); Console.WriteLine(" His life is rather short and fleeting."); Console.WriteLine("He's looking to you for guidance and protection."); Console.WriteLine("The length of his life is dependent on you!"); Console.WriteLine("press enter to continue"); Console.ReadKey(); Console.WriteLine("Good luck and have fun!!"); introDone = true; //This intro will only play once. After it ends. } while (introDone == false); Console.Clear(); //After the intro, the console clears before showing the menu options. string[] options = new string[] { "1. feed", "2. Clean up after", "3. Play with! ", "4. Kick!", " 5. Put to bed!", " 0. Exit application" }; Console.WriteLine("(^___^) " + userPetname + "Can't wait to play with you!!"); Console.WriteLine("Here are your options!: "); for (int i = 1; i < (i + 2); i++) //This creates an infinte loop for the game to continue running until the pet dies. { //The following displays the pet's current needs. Console.WriteLine("Hunger " + myPet.petHunger); Console.WriteLine("Dirty " + myPet.petPoop); Console.WriteLine("Boredom " + myPet.petBoredom); Console.WriteLine("Exhaustion: " + myPet.petEnergy); Console.WriteLine("Lifeforce: " + myPet.petAge); foreach (string optionsList in options) { Console.WriteLine(optionsList); } //This shows you your current options. int userOption = int.Parse(Console.ReadLine()); switch (userOption) { case 0: Console.WriteLine("Alrighty! Thank you for playing! Bye bye!"); Console.WriteLine("Press enter to exit the program!"); Console.ReadKey(); quit = true; break; case 1: Console.WriteLine("You feed " + userPetname); if (myPet.petHunger <= 90) { Console.WriteLine("(^___^) Thank for food!!! "); SoundPlayer eating = new SoundPlayer(@"C:\\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\Eat.wav"); { eating.PlaySync(); //Play sync makes game pause until the sound finishes. } myPet.Feed(); break; } else //If the pet's hunger level is higher than 90. myPet.Feed will not run. { Console.WriteLine(userPetname + " doesn't seem hungry.. I'd wait a while."); } break; case 2: Console.WriteLine("You clean up after" + userPetname); if (myPet.petPoop >= 0) { Console.WriteLine("(^w^) Thank for clean!!"); SoundPlayer cleanUp = new SoundPlayer(@"C:\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\Clean.wav"); { cleanUp.PlaySync(); } myPet.Clean(); break; } else { Console.WriteLine("I don't think it can get much cleaner than this..."); } break; //If the poop level is < 0. Then you cannot clean. case 3: Console.WriteLine("You play with " + userPetname); if (myPet.petBoredom >= 0) { Console.WriteLine("( ^w^ ) So much fun!!! "); SoundPlayer playTime = new SoundPlayer(@"C:\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\Play.wav"); { playTime.PlaySync(); //Yaaaaaaaay } myPet.Play(); break; } else { Console.WriteLine("He seems uninterested..."); } break; //If the pet's boredom level is 0 he won't play with you. case 4: Console.WriteLine("You kick " + userPetname + " !" + " Why would you do that?!?"); Console.WriteLine("(O___O;) "); myPet.Kick(); //MEAN!! break; case 5: Console.WriteLine("You tuck " + userPetname + " in bed..."); if (myPet.petEnergy <= 30) { Console.WriteLine(" But he isn't tired... "); break; } else { Console.WriteLine(" He looks so comfy!! "); SoundPlayer sleepyTime = new SoundPlayer(@"C:\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\sleepytime.wav"); { sleepyTime.PlaySync(); //Zzzzzzzzzz } myPet.ToBed(); } break; default: Console.WriteLine("You decide to do nothing? " + userPetname + " seems confused but content"); Console.WriteLine("Please try using one of the available options?"); break; } if (quit == true) { break; } if (myPet.petHunger <= 0) { SoundPlayer deathStarve = new SoundPlayer(@"C:\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\Diedstarvation.wav"); { deathStarve.PlaySync(); } Console.Clear(); Console.WriteLine("Uh oh... he isn't moving. I think he may have starved to death..."); Console.WriteLine("Was giving you a pet a bad idea?"); break; //Essentially, you can starve your pet to death once his hunger reaches 0. } if (myPet.petBoredom >= 200) { SoundPlayer ranAway = new SoundPlayer(@"C:\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\Diedstarvation.wav"); { ranAway.PlaySync(); } Console.Clear(); Console.WriteLine("Uh no... Looks like he got bored with you and ran away... "); Console.WriteLine("Pets can be fickle sometimes, huh?"); break; } //Another way to lose the game. If the pet's boredom goes to high. He'll run away. if (myPet.petEnergy >= 150) { SoundPlayer deathFromSleepy = new SoundPlayer(@"C:\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\Diedstarvation.wav"); { deathFromSleepy.PlaySync(); } Console.Clear(); Console.WriteLine("Oh no... Did you know you could die from being overtired?!"); Console.WriteLine("I don't think " + userPetname + " knew that either... "); break; } if (myPet.petPoop >= 150) { SoundPlayer poopyDemise = new SoundPlayer(@"C:\Users\WeCanCodeIT\Documents\Visual Studio 2015\Projects\VirtualPet\VirtualPet\sounds\Poop.wav"); { poopyDemise.PlaySync(); } Console.Clear(); Console.WriteLine("Things have gotten so dirty that you can't find" + userPetname); Console.WriteLine("I think he may have gotten buried in the mountain of poop..."); Console.WriteLine("I don't think he's okay in there... "); Console.WriteLine("Oh no... "); break; } if (myPet.petAge <= 0) { Console.Clear(); Console.WriteLine("Like most good things, your pet's life has come to an end."); Console.WriteLine("He truly enjoyed his time with you!"); Console.WriteLine("Hopefully, his memory will live on within your heart forever!"); Console.WriteLine("press enter to quit"); break; //The only way to die the "right" way. If life equals 0 he dies of old age. } } }
static void Main(string[] args) { //Random object for Tick Method Random rand = new Random(); //Pet Generator Console.WriteLine("Say hi to your new xenomorph!"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("What's your xenomorph's name?"); string xennyName = Console.ReadLine(); Pet xenny = new Pet(xennyName, 45.5, 5, "eager"); //quitFlag - if true, keep going bool quitFlag = false; //Main Program Logic do { xenny.StatusCheck(); Console.WriteLine(); MenuWriter(); string userInput = Console.ReadLine(); switch (userInput) { case "1": xenny.StatusCheck(); break; case "2": xenny.Bark(); break; case "3": xenny.PlaysVidya("amped"); break; case "4": xenny.PowerUp(9001); break; case "5": xenny.Feed(); break; case "6": xenny.Tick(rand.Next(6)); break; case "7": quitFlag = true; break; default: break; } }while (quitFlag == false); Console.WriteLine("Have a great day!"); }
static void Main(string[] args) { Console.WriteLine("Hello! Welcome to Virtual Pets"); Pet userPet = new Pet(); Shelter myShelter = new Shelter(); Organic organicPet = new Organic(); Robotic roboticPet = new Robotic(); myShelter.CreateNewPet(userPet, organicPet, roboticPet, myShelter); bool playingGame = true; while (playingGame) { Console.Clear(); foreach (Pet pet in myShelter.ListOfPets) { pet.GiveStats(); } userPet = myShelter.SelectPet(); Console.Clear(); userPet.GiveStats(); Console.WriteLine(); userPet.MenuOptions(); string menuChoice = Console.ReadLine(); switch (menuChoice) { case "1": userPet.Feed(); break; case "2": userPet.QuenchThirst(); break; case "3": userPet.Play(); break; case "4": userPet.SeeDoctor(); break; case "5": Console.WriteLine($"You did nothing."); break; case "6": Console.Clear(); myShelter.CreateNewPet(userPet, organicPet, roboticPet, myShelter); break; case "7": playingGame = false; Console.WriteLine("Thanks for playing!"); break; default: Console.WriteLine("Invalid input."); break; } userPet.Tick(); userPet.CheckHealth(); userPet.CheckHunger(); userPet.CheckThirst(); userPet.CheckBoredom(); Console.WriteLine("Press any key to continue."); Console.ReadKey(); } Console.ReadLine(); }
static void Main(string[] args) { Pet myPet = new Pet(); Console.WriteLine("Hello! Welcome to Virtual Pets\n"); Console.WriteLine("You have a new Virtual Pet. What kind of pet is it?"); myPet.SetSpecies(Console.ReadLine()); Console.WriteLine("What is your pet's name?"); myPet.SetName(Console.ReadLine()); Console.WriteLine($"{myPet.GetName()} the {myPet.GetSpecies()} is ready to play with you!\n\n"); Console.WriteLine("Press any key to start playing..."); Console.ReadKey(); Console.Clear(); bool playGame = true; do { myPet.Tick(); Console.WriteLine("\nWhat would you like to do?"); Console.WriteLine("1. See my pet's status"); Console.WriteLine("2. Play with my pet."); Console.WriteLine("3. Feed my pet."); Console.WriteLine("4. Take my pet to the doctor."); Console.WriteLine("5. Quit"); string gameAction = Console.ReadLine(); Console.Clear(); switch (gameAction) { case "1": myPet.ShowStatus(); break; case "2": myPet.Play(); break; case "3": myPet.Feed(); break; case "4": myPet.SeeDoctor(); break; case "5": Console.WriteLine("Your pet will miss you! Good-bye."); playGame = false; break; default: Console.WriteLine("Please enter a valid number."); break; } } while (playGame); }