Пример #1
0
        static void Main(string[] args)
        {
            //new instance of the pet
            VirtualPet myPet = new VirtualPet();


            //greet the user here
            Console.WriteLine("Hello, thank you for taking care of Ezra!");
            Console.WriteLine();


            int selectedOption;

            do
            {
                //these are the pet interactions
                Console.WriteLine();
                Console.WriteLine("What would you like to do today?");
                Console.WriteLine("1. Feed the pet");                //decreases hunger
                Console.WriteLine("2. Train the pet");               //increases intelligence
                Console.WriteLine("3. Give them water");             //decreases thirst
                Console.WriteLine("4. Play with them");              //decreases boredom
                Console.WriteLine("5. Tell the pet about your day"); //increases social need
                Console.WriteLine("6. Quit");                        //ends the game
                Console.WriteLine();



                selectedOption = int.Parse(Console.ReadLine());

                myPet.MyPetStatus();

                switch (selectedOption)
                {
                //when the user selects options, these switch cases change the stats
                case 1:

                    myPet.HungerDecrease();
                    Console.WriteLine("Thank you for feeding Ezra!");
                    break;

                case 2:

                    myPet.IntelIncrease();
                    Console.WriteLine("Ezra can now do new tricks!");
                    break;

                case 3:

                    myPet.ThirstDecrease();
                    Console.WriteLine("Thank you for keeping Ezra hydrated!");
                    break;

                case 4:

                    myPet.BoredomDecrease();
                    Console.WriteLine("Wow, Ezra sure is having fun!");
                    break;

                case 5:

                    myPet.SocialIncrease();
                    Console.WriteLine("Ezra certainly found your day interesting!");
                    break;

                case 6:

                    Console.WriteLine("Come back any time! (^_^)\"/\"");
                    break;

                default:

                    Console.WriteLine("Yikes! You chose to do nothing with that invalid option...");
                    break;
                }

                myPet.HungerIncrease();
                myPet.SocialDecrease();
                myPet.ThirstIncrease();
                myPet.BoredomIncrease();
            } while (selectedOption != 6);
        }
Пример #2
0
        static void Main(string[] args)
        {
            //this is how we instantiate a new instance of our pet
            VirtualPet myPet = new VirtualPet();


            //TODO add a greeting for the user. you can also let the user name the pet if you like
            Console.WriteLine("Hi, my name is, Glitch. Thank you for being my new friend!");

            int selectedOption; //I understand that this variable was defined for use later

            do                  //A do while loop! It makes so much sense now!
            {
                //TODO fill this out with more options to interact with the pet
                //Note to self MVP- Add more options later. Make it work first!

                Console.WriteLine("\nPlease select an option\n");
                Console.WriteLine("1. Feed me"); //Changed these options to sound like user was actually interacting with pet
                Console.WriteLine("2. Play a game with me");
                Console.WriteLine("3. Take me to the vet");
                Console.WriteLine("4. Give me water");
                Console.WriteLine("5. Take me to the bathroom");
                Console.WriteLine("10. Quit");
                Console.WriteLine("\n");

                selectedOption = int.Parse(Console.ReadLine()); //converts user input into a string to be used for interaction
                Console.WriteLine("\n");

                myPet.MyPetStatus();    //Note to self, Is this calling the class myPet? Figure out why this works...

                switch (selectedOption) //I remember switch case and prefer this option when it is a good fit
                {
                //when the user selects option one we feed the pet
                case 1:

                    myPet.HungerDecrease();
                    Console.WriteLine("Thank you, the food was yummy!\n");
                    break;

                case 2:     //when selected, user plays with the pet

                    myPet.LessBored();
                    Console.WriteLine("Thank you, I had so much fun playing!\n");
                    break;

                case 3:     //when selected, user takes Glitch to the vet

                    myPet.LessSick();
                    Console.WriteLine("Thank you, I feel much better!\n");
                    break;

                case 4:     //when selected, user gives pet water

                    myPet.LessThirsty();
                    Console.WriteLine("Thank you, that water was delicious!\n");
                    break;

                case 5:     //when selected, user takes glitch to the bathroom
                    myPet.GottaGoLater();
                    Console.WriteLine("Thank you for taking me to the bathroom.\n");
                    break;

                //TODO we need to add more cases for the other ways to interact with our pet

                case 10:

                    Console.WriteLine("Thank you for taking such great care of me.");
                    break;

                default:

                    Console.WriteLine("Invalid option selected.");
                    break;
                }

                //TODO We can put method calls here so the pet can have some values change automatically
                //Feel free to add, remove, or modify which methods are called here
                myPet.HungerIncrease();
                myPet.MoreThirsty();
                myPet.GottaGoNow();

                //***Your methods should cause the appropriate fields to update -
                //***for instance, if you have a Feed() method, it might make Hunger go down, but make Thirst go up.
                //Note to self: I understand that these methods are being called and that's why they work
                //figure out why calling the method works vs using an if else statement
                //also figure out if an if else can be used in a loop for more control of what increases and why
                //for example thirst increasing after eating or playing...
            } while (selectedOption != 10); //The switch was inside of a loop allowing the magic to happen.
                                            //it really makes so much sense now!
        }