public void ExecuteMenuChoice(string menuChoice) { switch (menuChoice) { case "1": myPet.AddPetToShelter(); myPet.SetPetName(); myPet.SetPetSpecies(); break; case "2": myPet.ViewPetInfo(); break; case "3": myPet.FeedPet(); break; case "4": myPet.PlayWithPet(); break; case "5": myPet.TakePetToDoctor(); break; default: break; } }
public void InteractWith1Pet() { Console.WriteLine("\nPlease select a pet from the above list."); // list of all pets here with its corresponding index ShowPetInfoWithID(); //user chooses pet(also contains the conversion syntax) int userChoice = Convert.ToInt32(Console.ReadLine()); //look up users petchoice in list //set new pet to pet choice within our list VirtualPet myPet = myPetList[userChoice - 1]; string menuChoice = ""; bool userIsPlaying = true; //while loop starts here while (userIsPlaying) { Console.WriteLine("\nWhat Would You Like To Do With Your Pet?"); Console.WriteLine("1. Feed Pet"); Console.WriteLine("2. Play With Pet"); Console.WriteLine("3. Take Pet To The Doctor"); Console.WriteLine("4. Exit"); menuChoice = Console.ReadLine(); switch (menuChoice) { case "1": myPet.FeedPet(); break; case "2": myPet.PlayWithPet(); break; case "3": myPet.TakePetToDr(); break; case "4": userIsPlaying = false; break; default: break; } } }
static void Main(string[] args) { //Instantiate the pet VirtualPet pet1 = new VirtualPet("Hairy", true, true, false, false, 0); //Instantiate variable for user choice. int userPick; //Print menu of user options. do { Console.WriteLine("\nWhat would you like to do? Enter the number of the menu item, and then click \"Enter\"."); List <string> userMenu = new List <string> { "1. Show me my pet's info.", "2. Feed pet.", "3. Water pet.", "4. Care for sick pet.", "5. Play with pet.", "6. Take pet outside.", "7. Exit." }; foreach (string menuItem in userMenu) { Console.WriteLine(menuItem); } //User input userPick = int.Parse(Console.ReadLine()); //Conditionals, based on user choice. switch (userPick) { case 1: Console.WriteLine("Here is information about your virtual pet:"); pet1.PetStats(); break; case 2: Console.WriteLine("You are feeding your pet."); pet1.FeedPet(); break; case 3: Console.WriteLine("You are watering your pet."); pet1.WaterPet(); break; case 4: Console.WriteLine("You are caring for your sick pet."); pet1.CareForPet(); break; case 5: Console.WriteLine("You are playing with your pet."); pet1.PlayWithPet(); break; case 6: Console.WriteLine("You are taking your pet outside to go potty."); pet1.TakePetOutside(); break; case 7: Console.WriteLine("Have a good day!"); break; default: Console.WriteLine("Please enter a valid option."); break; } }while (userPick != 7); }
static void Main(string[] args) { //This part allows the user to assignin random numbers to fields. Random random = new Random(); int Hunger = random.Next(90, 100); int Thirst = random.Next(50, 70); //PROPERTIES VirtualPet userPet = new VirtualPet(); userPet.Hunger = Hunger; userPet.Thirst = Thirst; //UI Console.WriteLine("Welcome to the Virtual Pet Shelter!\n Please enter your employee type \n 1- for Manager \n 2- for Volunteer."); Console.WriteLine(" Great! - Press any key to view pets status and choose further action..."); Console.ReadLine(); Console.Clear(); do { userPet.GetStatus(); //if (userImput ==1) //USER MENU 1 (Manager Menu) Console.WriteLine("What would you like to do?"); Console.WriteLine("\tPress 1 to feed {0}.", userPet.PetsName); Console.WriteLine("\tPress 2 to give {0} water.", userPet.PetsName); Console.WriteLine("\tPress 3 to play with {0}.", userPet.PetsName); Console.WriteLine("\tPress 4 to adopt {0}.", userPet.PetsName); Console.WriteLine("\tPress 5 to quit the game."); int userChoice = int.Parse(Console.ReadLine()); while (userChoice < 1 || userChoice > 5) { Console.WriteLine("You must choose 1 - 4 from the menu!\nWhat do you want to do for your pets?"); userChoice = int.Parse(Console.ReadLine()); } switch (userChoice) { case 1: { userPet.FeedPet(); } break; case 2: { userPet.WaterPet(); } break; case 3: { userPet.PlayWithPet(); break; } case 4: { Console.WriteLine("{0} says, \"Has been adopted!\"", userPet.PetsName); Console.WriteLine("the pets are very happy"); Environment.Exit(0); } break; case 5: { Console.WriteLine("{0} says, \"What a great worker!\"", userPet.PetsName); Console.WriteLine("the pets are very happy"); Environment.Exit(0); } break; // else (userImput == 2) // USER MENU 2 - Volunteer Menu goes here with additional switch case dialogue } Console.WriteLine("Press any key to continue"); Console.ReadLine(); } while (userPet.PetHappiness <= 75); //this section is what prints to the console when the virtual puppy's satisfaction is greater than or equal to 75). //Console.WriteLine("\nCongratulations {0}!\nYou have made {1} very happy today!\nThanks for playing Virtual Pet Shelter!", userPet.PetsName); } //MAIN