Esempio n. 1
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
            //Added greeting for user and prompted user to input a name for their pet tiger
            Console.WriteLine("Hello! Welcome to Virtual Pet Tiger.");
            Console.WriteLine("\r\n\r\nYou will be taking care of your very own pet tiger!");
            Console.WriteLine("\r\n\r\nPlease enter a name for your tiger: ");

            //Declare string variable and define it with user-given pet name
            string tigerName = Console.ReadLine();

            //Keep user informed about the name they chose
            Console.WriteLine("\r\n\r\nAwesome! Meet " + tigerName + ", your new pet tiger!");
            //Store ASCII art of tiger's face in a string; use Environment.NewLine to connect each line together
            string tigerFace = ("                           _" + Environment.NewLine +
                                "        __       __       ' `." + Environment.NewLine +
                                "      .'  `.  .-'\\`-.  ./   |" + Environment.NewLine +
                                "      |     \\-'-'_\\`-`_/    |" + Environment.NewLine +
                                "      |      \\--'-\\-._-.'/  )" + Environment.NewLine +
                                "      \\  \\ .'.'--'|\\`--._`.-'." + Environment.NewLine +
                                "       )`' .''' .'.-L-.`-.\\ '." + Environment.NewLine +
                                "      // _'/J '- ///|\\\\|-.``.`'." + Environment.NewLine +
                                "    .'/'/ .'.-`( | '|` ..-.'( L- L" + Environment.NewLine +
                                "   // |J J|]`((\"\\)\\ J(\".'`J||- |" + Environment.NewLine +
                                "  / | |) || Y.`.`\\.' -. L' - J ||| - -" + Environment.NewLine +
                                " /. ' |`.J|J\\  ))J' / \"-. \\`'/'/-  \"" + Environment.NewLine +
                                "J - -  \\  L\\`.-' || .' \\ \\`'J J  |" + Environment.NewLine +
                                " | -'_-'. (= `.//.-.__ \" _  L-/.-. |" + Environment.NewLine +
                                "| -      )_\\\\`|...(`-.\".''.)/ -.  )---" + Environment.NewLine +
                                " | -'')  `\\.::::.`.|/.:.'`-  ``--._" + Environment.NewLine +
                                "J - ' -'.'  )./ \\::::::'X::::\\` ``` ____" + Environment.NewLine +
                                ") \\ ' '//  ///''.__-'--`-\\\\ \\ `__" + Environment.NewLine +
                                "|\\' .' /|/ ' '///  ' \"` \\|\\`` -.`--." + Environment.NewLine +
                                "| `.'    /.' )  | (       )``-'  . `." + Environment.NewLine +
                                "J   `.'_.' /  / '''.____.'.'.-' | `.  `" + Environment.NewLine +
                                "(`.   `-.') . \" _.'. .'  '.'`  `." + Environment.NewLine +
                                "|`.\\     \'  \\  )' |)/    .- ' |  .'" + Environment.NewLine +
                                "/  `.\\    `.\\  /|.'//  .-'    J /" + Environment.NewLine +
                                "     `.     \\`\" )//   //       L" + Environment.NewLine +
                                "     _ `     ` . /  .''  _.--'' |" + Environment.NewLine +
                                "    --._      '|`  .'.'-\"\"-` |\";" + Environment.NewLine);

            Console.WriteLine(tigerFace);


            //Declare int variable for user menu selection
            int selectedOption;

            //Create a do while loop for user menu with options
            do
            {
                //TODO fill this out with more options to interact with the pet
                //Added seven menu options for user
                Console.WriteLine();
                Console.WriteLine(tigerName + " the Tiger");
                Console.WriteLine("\r\n\r\nPlease select an option:");
                Console.WriteLine("1 - Feed " + tigerName + ".");
                Console.WriteLine("2 - Give " + tigerName + " a drink of water.");
                Console.WriteLine("3 - Take " + tigerName + " out for a bathroom break.");
                Console.WriteLine("4 - Go on an exciting adventure with " + tigerName + ".");
                Console.WriteLine("5 - Let " + tigerName + " get some sleep.");
                Console.WriteLine("6 - Give " + tigerName + " a bath.");
                Console.WriteLine("7 - Quit the game.");
                Console.WriteLine();
                Console.WriteLine("**Try not to let tiger's stats reach zero.**");
                Console.Write("> ");

                //store user selection in variable and convert to int
                selectedOption = int.Parse(Console.ReadLine());
                Console.Clear();


                //use switch case to determine reactions to user selections
                switch (selectedOption)
                {
                //when the user selects option one we feed the pet
                case 1:

                    myPet.HungerScoreHigher();
                    myPet.ThirstScoreLower();    //Tiger gets thirsty when eating
                    myPet.WasteScoreLower();     //Tiger will have to go to the bathroom
                    Console.WriteLine("\r\n\r\nThank you for feeding " + tigerName + "!");
                    break;

                //TODO we need to add more cases for the other ways to interact with our pet
                //when the user selects option two we give tiger a drink
                case 2:

                    myPet.ThirstScoreHigher();
                    myPet.WasteScoreLower();     //Tiger will have to go to the bathroom
                    Console.WriteLine("\r\n\r\nYou gave " + tigerName + " some water!");
                    break;

                case 3:

                    myPet.WasteScoreHigher();
                    Console.WriteLine("\r\n\r\n" + tigerName + " went out for a much needed bathroom break.");
                    break;

                case 4:

                    myPet.BoredomScoreHigher();
                    myPet.HungerScoreLower();     //Tiger works up an appetite during an adventure
                    myPet.ThirstScoreLower();     //Tiger is thirsty after all that adventuring
                    myPet.FatigueScoreLower();    //Exciting adventures make tiger sleepy
                    Console.WriteLine("\r\n\r\nYou went on a wild adventure with " + tigerName + "!!");
                    break;

                case 5:

                    myPet.FatigueScoreHigher();
                    myPet.WasteScoreLower();     //Tiger may need to use the bathroom after waking up
                    Console.WriteLine("\r\n\r\n" + tigerName + " is well-rested now thanks to a nice long cat nap.");
                    break;

                case 6:

                    myPet.HygieneScoreHigher();
                    myPet.BoredomScoreLower();     //Bathing is kinda boring for tiger
                    Console.WriteLine("\r\n\r\nWonderful! " + tigerName + " is sparkling clean!");
                    break;

                case 7:

                    Console.WriteLine("Thank you for playing.. " + tigerName + " is gonna miss you!!");
                    Console.WriteLine("\r\n\r\nPlease help support Tiger conservation efforts: \r\n\r\nPeople and tigers increasingly compete for space.\r\nThe conflict threatens the world’s remaining wild tigers and poses a major problem for communities living in or near forests with tigers.\r\nAs forests shrink and prey gets scarce, tigers are forced to hunt domestic livestock, which many local communities depend on for their livelihood.\r\nIn retaliation, tigers are killed or captured.\r\n“Conflict” tigers are known to end up for sale in black markets.\r\nLocal community dependence on forests for fuelwood, food and timber heightens the risk of tiger attacks on people.\r\nContact the World Wildlife Foundation for more information.");
                    return;

                default:

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

                Console.WriteLine();
                //Print out tiger face to console before each status update
                Console.WriteLine(tigerFace);
                //call on method to give pet status update
                myPet.MyPetStatus();
                //call on method to let pet do random stuff
                myPet.UnpredictablePet();
                //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

                //Use if statements to determine when each score should automatically lower based upon user selections
                if (selectedOption != 1)
                {
                    myPet.HungerScoreLower();
                }


                if (selectedOption != 4)
                {
                    myPet.BoredomScoreLower();
                }

                if (selectedOption != 5)
                {
                    myPet.FatigueScoreLower();
                }

                if (selectedOption != 6)
                {
                    myPet.HygieneScoreLower();
                }
            } while (selectedOption != 7);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //This program is a virtual pet program.  The user practices taking care of a virtual pet.
            //The program tracks the status of the pet and gives the user a score which represents their
            //skill at taking care of their pet.

            //Future improvements planned:  update user score in random events
            //                              prevent a random event from occuring twice
            //                              add more random events
            //                              allow a random event to terminate the program


            string input = "";                           // user input
            string userName;                             // user's name
            string petName;                              // pet's name

            string[] menu = new string[10];              // stores menu choices

            int    selectedOption = -1;                  // menu choice (parsed from input)
            int    counter        = 0;                   // counter
            int    randomNumber   = -1;                  // random number
            double score          = 0;                   // user's score
            double number;                               // dummy variable to hold temporary information
            double time, newTime, elapsedTime;           // time variables to determine elapsed time
            double rndTime, newRndTime;                  // elapsed time for random function


            bool quit;                                   // tests whether to quit the program

            VirtualPet myPet = new VirtualPet();         //instantiate a new Virtual Pet
            Random     rnd   = new Random();             // setup random number generator

            userName = Greet();                          // Greet the user and get their name
            petName  = GetPetName(userName);             // Select pet name
            if (petName != "")
            {
                myPet.Name = petName;                    // Set pet name based on user input (unless it is blank)
            }
            petName = myPet.Name;                        // set petName to myPet.Name which will be either default or user input


            //personalize menu choices with name of pet
            //this was setup this way in case I wanted to add more pet options in the future and vary the menu
            //for each different type of pet.  It is not necessary for the program as it is now.
            menu[1] = "  1. Feed " + myPet.Name + ".";
            menu[2] = "  2. Give " + myPet.Name + " water.";
            menu[3] = "  3. Take " + myPet.Name + " out to use the bathroom.";
            menu[4] = "  4. Take " + myPet.Name + "to the park to play.";
            menu[5] = "  5. " + myPet.Name + " isn't feeling well.  Take him to the vet.";
            menu[6] = "  6. Quit";


            time    = DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second; //get current time
            rndTime = time;
            do
            {
                counter++;
                if (counter > 4)                                   //automatic changes to pet attributes based on time don't start until the 5th loop
                                                                   //this gives the user a chance to get used to the program before it gets more difficult.
                {
                    score       = myPet.Warnings(userName, score); // print warnings if pet is in danger and adjust user score
                    newTime     = DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second;
                    elapsedTime = newTime - time;                  // calculate elapsed time since last menu entry
                    if (elapsedTime < 0)
                    {
                        elapsedTime = 0;
                    }
                    if (elapsedTime > 20)
                    {
                        elapsedTime = 20;                                      //caps the elapsed time so that changes are not too great
                    }
                    myPet.HungerChange(elapsedTime * 0.2);                     //increase hunger as time goes by
                    myPet.ThirstChange(elapsedTime * 0.2);                     //increase thirst as time goes by
                    myPet.WasteChange(elapsedTime * 0.2);                      //increase waste as time goes by
                    myPet.BoredomChange(elapsedTime * 0.2);                    //increase boredom as time goes by
                    time = newTime;
                }
                quit = myPet.Terminate;                                    // get current terminate status

                if (!quit)
                {
                    myPet.MyPetStatus(userName, score);                       // print pet's current status

                    //set random events
                    randomNumber = rnd.Next(1, 50);                                                                  // pick random number between 1 and 100
                    newRndTime   = DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second;
                    if ((newRndTime - rndTime) > 15)                                                                 // set minimum frequency of random events in seconds
                    {
                        rndTime = myPet.RandomEvent(randomNumber, newRndTime, userName, myPet.Name, score, rndTime); // get random event
                    }
                    Console.WriteLine();
                    Console.WriteLine("\r\n  Please select an option:\r\n");  // prompt user for menu choice
                    for (int i = 0; i < 7; i++)
                    {
                        Console.WriteLine(menu[i]);                               // print menu choices for user
                    }


                    input          = Console.ReadLine().Trim().ToLower();         // read user input
                    selectedOption = GetInput(input);                             // call method GetInput to validate user input
                }
                else
                {
                    selectedOption = 6;                                          // terminate program if terimate=true
                }


                switch (selectedOption)                                       // perform action based on user input
                {
                case 1:                                                       // feed the pet

                    myPet.HungerChange(-1);
                    Console.Clear();
                    Console.WriteLine("\r\n\t\tThank you for feeding {0}!", myPet.Name);
                    break;

                case 2:                                                       // give pet water

                    myPet.ThirstChange(-1);
                    Console.Clear();
                    Console.WriteLine("\r\n\t\tThank you for giving {0} water!", myPet.Name);
                    break;

                case 3:                                                       // bathroom break!

                    myPet.WasteChange(-0.7);
                    Console.Clear();
                    Console.WriteLine("\r\n\tThank you for letting {0} outside to go potty!", myPet.Name);
                    break;

                case 4:                                                      // play with pet

                    myPet.BoredomChange(-1);
                    myPet.HungerChange(0.2);
                    myPet.ThirstChange(0.4);
                    myPet.SickChange(-0.2);
                    myPet.WasteChange(-0.5);
                    Console.Clear();
                    Console.WriteLine("\r\n\t\t{0} had a wonderful time with you!", myPet.Name);
                    break;

                case 5:                                                     // take pet to vet

                    myPet.SickChange(-2);
                    Console.Clear();
                    number = myPet.Sick;
                    if (number < 5)
                    {
                        Console.WriteLine("\r\n\t{0} feels so much better now.  Thank you!", myPet.Name);
                    }
                    if (number < 8 && number >= 5)
                    {
                        Console.WriteLine("\r\n\t{0} feels much better, but you should propbably\r\n\tkeep a close eye on him.", petName);
                    }
                    if (number >= 8)
                    {
                        Console.WriteLine("\r\n\tThank you for taking {0} to the vet. He is still not feeling well\r\n\tand may need another visit.", petName);
                    }
                    break;

                case 6:                                                     // quit

                    Console.WriteLine("\r\n\tThank you for playing, {0}.  Your final score is:  {1}", userName, score);
                    Console.WriteLine("\r\n\r\n\r\n\r\nPress return to exit...");
                    Console.ReadLine();
                    break;

                default:

                    Console.WriteLine("*** Invalid option selected.\r\n\r\nPress any key to continue...");
                    Console.ReadKey();
                    break;
                }
            } while (selectedOption != 6);
        }
        static void Main(string[] args)
        {
            //create a pet to use as an object for calling PrintCenter()
            //Is there a better way to do this?
            VirtualPet aPet = new VirtualPet();

            //Welcome text introducing user to the page.
            string welcome  = "Welcome to dragon training!";
            string welcome1 = "Oh, wait, sorry. This isn't Berk.";
            string welcome2 = "What I meant to say was:";
            string welcome3 = "WELCOME TO THE DRAGON HATCHERY";

            //print centered welcome text
            aPet.PrintCenter(welcome);
            aPet.PrintCenter(welcome1);
            aPet.PrintCenter(welcome2);
            aPet.PrintCenter(welcome3);

            //create space
            Console.WriteLine();
            Console.WriteLine();

            //Introduction text - introduces dragons and some of the guidelines
            string intro   = "So you want to adopt a dragon.";
            string intro1  = "Before you decide to go through with the adoption";
            string intro2  = "there are a few things you should know.";
            string intro3  = "As with other animals, dragons need food, water, exercise and sleep.";
            string intro4  = "In addition, however, dragons have an innate need to...vent.";
            string intro5  = "Basically, they must be allowed to wreak devestation.";
            string intro6  = "Fire and teeth and claws and all that.";
            string intro7  = "Make sure you have a proper wilderness on loan where you can";
            string intro8  = "bring your dragon for this purpose!";
            string intro9  = "It's truly a dreadful thing when our customers try";
            string intro10 = "to keep their dragons pent up.";
            string intro11 = "Truly dreadful. You can't imagine the ... well, enough of that.";

            //print centered intro text
            aPet.PrintCenter(intro);
            aPet.PrintCenter(intro1);
            aPet.PrintCenter(intro2);
            Console.WriteLine();
            aPet.PrintCenter(intro3);
            aPet.PrintCenter(intro4);
            aPet.PrintCenter(intro5);
            aPet.PrintCenter(intro6);
            aPet.PrintCenter(intro7);
            aPet.PrintCenter(intro8);
            Console.WriteLine();
            aPet.PrintCenter(intro9);
            aPet.PrintCenter(intro10);
            aPet.PrintCenter(intro11);

            Console.WriteLine("\r\n\r\n\r\nPress any key to continue");
            Console.ReadKey();
            Console.Clear();

            //guideline text
            string guide  = "Just some general things to keep an eye out for:";
            string guide1 = "Your dragon will let you know what he needs.";
            string guide2 = "When he needs something, his levels will rise.";
            string guide3 = "Just make sure you don't let them rise above 25!";
            string guide4 = "You might not like the consequences...";
            string guide5 = "When his needs are met, his levels will sit around 0.";
            string guide6 = "Another word of warning, don't try to push him past what he needs.";
            string guide7 = "If they enter the negatives, beware!";

            //print centered guideline text
            Console.WriteLine();
            aPet.PrintCenter(guide);
            Console.WriteLine();
            aPet.PrintCenter(guide1);
            Console.WriteLine();
            aPet.PrintCenter(guide2);
            aPet.PrintCenter(guide3);
            aPet.PrintCenter(guide4);
            Console.WriteLine();
            aPet.PrintCenter(guide5);
            aPet.PrintCenter(guide6);
            aPet.PrintCenter(guide7);

            Console.WriteLine("\r\n\r\n\r\n\r\nPress any key to continue");
            Console.ReadKey();
            Console.Clear();

            //outro text leading to game
            string last  = "Okay, do you want to continue with the adoption?";
            string last1 = "Oh, good. We weren't going to let you escape, anyways!";
            string last2 = "There are so few willing to adopt dragons these days...";
            string last3 = "Well, on to the final question before we send you on your way!";
            string last4 = "What would you like to name your dragon?";

            //print centered outro text
            aPet.PrintCenter(last);
            Console.ReadLine(); //give user chance to "enter" answer, even though it doesn't matter
            Console.WriteLine();
            aPet.PrintCenter(last1);
            aPet.PrintCenter(last2);
            aPet.PrintCenter(last3);
            Console.WriteLine();

            //Get user to name the pet
            aPet.PrintCenter(last4);
            string petName = Console.ReadLine();

            //Wish user and dragon luck
            string sendOff  = "Best of luck to you and " + petName + ".";
            string sendOff2 = "We hope the two of you enjoy a long and happy relationship!";

            //print centered send-off text
            Console.WriteLine();
            Console.WriteLine();
            aPet.PrintCenter(sendOff);
            aPet.PrintCenter(sendOff2);

            //instantiate a new instance of the pet
            VirtualPet myPet = new VirtualPet(petName);

            //declare variables that will be used in the do/while loop
            string userOption;     //stores which menu option user chooses
            int    selectedOption; //stores which menu option the user chooses as an int after TryParse
            int    ctr = 0;        //will count how many times the loop has run

            //clear screen and enter game
            Console.WriteLine("\r\n\r\n\r\n\r\nPress any key to continue");
            Console.ReadKey();
            Console.Clear();

            do
            {
                //list the alternate scenarios the user will encounter based on the number of times they have cycled through the loop
                if (ctr == 8 || ctr == 34)
                {
                    Console.ReadKey();
                    Console.Clear();
                    myPet.WatchNeighborDragon();

                    Console.WriteLine();
                    Console.WriteLine("\r\nPress any key to continue");
                    Console.ReadKey();
                    Console.WriteLine();
                }

                else if (ctr == 16 || ctr == 44)
                {
                    Console.ReadKey();
                    Console.Clear();
                    myPet.PetRunsAwayScenario();
                }

                else if (ctr == 24 || ctr == 54)
                {
                    Console.ReadKey();
                    Console.Clear();
                    myPet.SickPetScenarioGeneral();
                }

                else
                {
                    //even if there's not any other possible condition, should I have an else statement, even if it's blank?
                }

                //call method that checks to see if stats are too high or two low and respond accordingly
                myPet.StatConsequences();

                //creates space between iteration and also between asking for pet name and stat display
                Console.WriteLine();

                //display updated pet status above the menu
                myPet.MyPetStatus();

                //Menu of options for user actions
                Console.WriteLine();
                Console.WriteLine("Please select an option:");
                Console.WriteLine("1. Feed your dragon 5 head of cattle");
                Console.WriteLine("2. Go to the lake");
                Console.WriteLine("3. Practice flying maneuvers");
                Console.WriteLine("4. Play \"hide the treasure\" (fake treasure of course!)");
                Console.WriteLine("5. Fly to wildlands (here your dragon can vent!)");
                Console.WriteLine("6. Sleep under the stars");
                Console.WriteLine("7. Host a barbeque, courtesy of dragon fire!");
                Console.WriteLine("10. Quit");

                //record user choice
                userOption = Console.ReadLine();

                //Create space between menu and user options
                Console.WriteLine();

                //create a random number generator that will randomly call Tick()
                Random RandomGenerator = new Random();
                int    randomNum       = RandomGenerator.Next(0, 3);

                //Send user to Tick() if their input is invalid
                if (!int.TryParse(userOption, out selectedOption))
                {
                    myPet.Tick(1);

                    Console.WriteLine();
                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                }

                //randomly send user to Tick().
                else if (randomNum == 2)
                {
                    Console.WriteLine();
                    myPet.Tick(selectedOption);

                    Console.WriteLine();
                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                }

                //Filter user input to appropriate menu option
                else if (int.TryParse(userOption, out selectedOption))
                {
                    switch (selectedOption)
                    {
                    //user selects 1 = feed the pet
                    case 1:

                        myPet.FoodDecrease();
                        myPet.FoodDecrease();

                        //other values increase
                        myPet.WaterIncrease();
                        myPet.ExerciseIncrease();
                        myPet.DestructionIncrease();

                        //response to user action
                        Console.WriteLine("Nothing beats a good steak.");
                        break;

                    //user selects 2 = water the pet
                    case 2:

                        myPet.WaterDecrease();

                        //other values increase
                        myPet.DestructionIncrease();

                        //response to user action
                        Console.WriteLine("Your dragon has thoroughly enjoyed your excursion and has replentlished its store of water");
                        break;

                    //user selects 3 = fly pet
                    case 3:

                        myPet.ExerciseDecrease();
                        myPet.ExerciseDecrease();

                        //other values decrease
                        myPet.DestructionDecreaseGeneral();

                        //other values increase
                        myPet.FoodIncrease();
                        myPet.WaterIncrease();
                        myPet.SleepIncrease();

                        //response to user action
                        Console.WriteLine("There's nothing like the feeling of soaring through the sky.");
                        break;

                    //user chooses 4 = play treasure game
                    case 4:

                        myPet.ExerciseDecrease();

                        //other values increase
                        myPet.FoodIncrease();
                        myPet.WaterIncrease();
                        myPet.SleepIncrease();
                        myPet.DestructionIncrease();

                        //response to user action
                        Console.WriteLine("Use that dragon instinct for teasure! \r\n Of course, make sure you stay ahead of him and hide it well. \r\nDragons are remarkably intelligent!");
                        break;

                    //user chooses 5 = wilderness trip
                    case 5:

                        myPet.DestructionDecreaseWilderness();
                        myPet.ExerciseDecrease();
                        myPet.ExerciseDecrease();
                        myPet.ExerciseDecrease();

                        //other values increase
                        myPet.FoodIncrease();
                        myPet.FoodIncrease();
                        myPet.WaterIncrease();
                        myPet.WaterIncrease();
                        myPet.SleepIncrease();
                        myPet.SleepIncrease();

                        //response to user action
                        Console.WriteLine("If you don't have a healthy respect for dragons, you do now!");
                        break;

                    //user chooses 6 = sleep
                    case 6:

                        myPet.SleepDecrease();

                        //other values increase
                        myPet.FoodIncrease();
                        myPet.WaterIncrease();
                        myPet.ExerciseIncrease();
                        myPet.DestructionIncrease();
                        myPet.DestructionIncrease();

                        //response to user action
                        Console.WriteLine("Hopefully where you live the skies are clear. \r\nNothing like a summer evening streaked with shooting stars");
                        break;

                    //user chooses 7 = barbeque
                    case 7:

                        myPet.DestructionDecreaseGeneral();
                        myPet.FoodDecrease();

                        //other values increase
                        myPet.WaterIncrease();
                        myPet.WaterIncrease();
                        myPet.SleepIncrease();

                        //response to user actions
                        Console.WriteLine("Remember the days when barbeques used to be a lot of work? \r\n Gone forever! \r\n\r\nLife is good.");
                        break;

                    //user chooses 10 = quit
                    case 10:

                        Console.WriteLine("It was lovely to meet you. " + petName + " will greatly miss you. We hope you will return soon!");
                        break;

                    default:

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

                    //pauses screen after response to user, and they have to push a key to keep going
                    Console.WriteLine();
                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                } // is the ending of the else if statement that the program runs if tick isn't called.

                else
                {
                }      // need an empty else statement to end the conditionals if don't have anything to put in it?

                ctr++; // keep track of how many times the loop has cyled through.

                //create space between each iteration for readability
                Console.WriteLine();
            } while (selectedOption != 10);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //this is how we instantiate a new instance of our pet

            //int hunger = 1;
            //int thirst = 2;

            //TODO add a greeting for the user. you can also let the user name the pet if you like

            Console.WriteLine("Hello and welcome to Virtual Petland!");
            Console.WriteLine("What would you like to name your pet kangaroo?");
            string     petName = Console.ReadLine();
            VirtualPet myPet   = new VirtualPet(petName, 1, 2, "pat", "run", "jump");
            int        selectedOption;

            do
            {
                //TODO fill this out with more options to interact with the pet
                Console.WriteLine();
                Console.WriteLine("Please select an option between 1 and 5.  Type 'Q' to Quit ");
                Console.WriteLine("1. Feed " + petName);
                Console.WriteLine("2. Give " + petName + " something to drink");
                Console.WriteLine("3. Take " + petName + " for a run");
                Console.WriteLine("4. Pat " + petName + " on the head");
                Console.WriteLine("5. Tell " + petName + " to do a trick");
                Console.WriteLine("'10'. Quit");
                selectedOption = int.Parse(Console.ReadLine());

                while (selectedOption >= 1 && selectedOption <= 5)
                {
                    ;
                }

                myPet.MyPetStatus();

                switch (selectedOption)
                {
                //when the user selects option one we feed the pet
                //when the user selects option two we give the pet a drink
                //when the user selects option three we pat the pet on the head
                //when the user selects option four we take the pet for a run
                //when the user selects option five we ask the pet to jump through a hoop
                case 1:
                    myPet.HungerDecrease();
                    Console.WriteLine("Thank you for feeding the pet");
                    Console.WriteLine("Bubbles has been fed, and hunger Level has been decreased");
                    break;

                case 2:
                    myPet.ThirstDecrease();
                    Console.WriteLine(petName + " thanks you for the water!");
                    Console.WriteLine("Bubbles has been fed, and hunger Level has been decreased");
                    break;

                case 3:
                    myPet.TouchPet();
                    Console.WriteLine("What a sweet thing to do for " + petName);
                    Console.WriteLine("Bubbles has been fed but may still be a little hungry. Hunger Level has been decreased");
                    break;

                case 4:
                    myPet.ExercisePet();
                    Console.WriteLine("Oh what fun to take " + petName + "for a run!");
                    break;

                case 5:
                    myPet.TricksPet();
                    Console.WriteLine(petName + " likes to jump through hoops. What fun!");
                    break;

                case 6:
                    Console.WriteLine("Pat on the head");
                    break;

                case 7:
                    Console.WriteLine("Ride in " + petName + "'s pouch");
                    break;

                case 8:
                    Console.WriteLine("Give " + petName + "a hug");
                    break;

                case 9:
                    Console.WriteLine(petName + " thanks you for the love!");
                    break;

                case 10:
                    Console.WriteLine(petName + " has enjoyed spending time with you. Good-bye! ");
                    Console.WriteLine("Thank you for playing with" + petName);
                    break;

                default:
                    Console.WriteLine("Pick a valid option");
                    break;

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

                //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.HungerDecrease();

                {
                    Console.WriteLine("Invalid option. Please select a number between 1 and 5, or select '10' to Quit");
                }
                Console.WriteLine("Please select an option to touch " + petName);
                Console.WriteLine("Select 1 to pat " + petName + "on the head");
                Console.WriteLine("Select 2 to ride in " + petName + "'s pouch");
                Console.WriteLine("Select 3 to hug " + petName);
                Console.WriteLine("Select '10' to Quit");
            }while (selectedOption < 5 && selectedOption > 1);
            {
                Console.WriteLine("That was great! Select another option to keep playing!");
            }
        }
Esempio n. 5
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);
        }
Esempio n. 6
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!
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            // Introduction and Pet Naming
            VirtualPet myPet = new VirtualPet();

            Console.Write("Hello!  Welcome to VirtuaPet! \n\n" +
                          "           _          (`-." + "\n" +
                          "           \\`----.    ) ^_`)" + "\n" +
                          "     ,__    \\__  `\\_ /  (  `" + "\n" +
                          "      \\_\\     \\__  `|   }" + "\n" +
                          "        \\\\  .-' \\__/    }" + "\n" +
                          "         ))/   \\__,<  /_/" + "\n" +
                          "         ((|  _/_/ `\\ \\_\\_" + "\n" +
                          "           '\\____\\\\  )__\\_\\" + "\n");

            Console.Write("\n\nWould you like to name your Gryphon?(y/n): ");
            string nameQuest = Console.ReadLine().ToLower();

            myPet.PetName(nameQuest);
            //if (nameQuest == "y" || nameQuest=="yes")
            //{
            //    myPet.PetName();
            //}
            //else if(nameQuest=="n" || nameQuest == "no")
            //{

            //}
            //else
            //{
            //    Console.WriteLine("Invalid answwer, would you like to name your Gryphon (y/n)?: ");
            //    nameQuest = Console.ReadLine().ToLower();

            //        myPet.PetName();

            //}


            // Main Menu
            int selectedOption;

            do
            {
                myPet.MyPetStatus();

                Console.WriteLine();
                Console.WriteLine("Please select an option");
                Console.WriteLine("1. Feed your Gryphon");
                Console.WriteLine("2. Give your Gryphon a drink");
                Console.WriteLine("3. Put your Gryphon to bed");
                Console.WriteLine("4. Play with your Gryphon");
                Console.WriteLine("5. Discipline your Gryphon");
                Console.WriteLine("6. Rename Gryphon");
                //Console.WriteLine("7. Have your pet do a trick");
                //Console.WriteLine("8. Advanced Options");
                Console.WriteLine("7. Quit");

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

                switch (selectedOption)
                {
                // Feed Pet
                case 1:
                    myPet.FeedPet();
                    if (myPet.DeathCheck())
                    {
                        Console.WriteLine("\nGAME OVER!!");
                        selectedOption = quitOption;
                        break;
                    }
                    break;


                // Hydrate Pet
                case 2:
                    myPet.HydrationIncrease();
                    myPet.ActivityDecrease();
                    if (myPet.DeathCheck())
                    {
                        Console.WriteLine("\nGAME OVER!!");
                        selectedOption = quitOption;
                        break;
                    }
                    Console.WriteLine("Ahhh");
                    break;


                // Pet Sleep
                case 3:
                    myPet.BehaviorIncrease();
                    myPet.HitPointsIncrease();
                    myPet.ManaIncrease();
                    myPet.ActivityDecrease();
                    if (myPet.DeathCheck())
                    {
                        Console.WriteLine("\nGAME OVER!!");
                        selectedOption = quitOption;
                        break;
                    }
                    Console.WriteLine("I feel much better after a nap, is what I would say if I could talk!");
                    break;


                // Play with Pet
                case 4:
                    myPet.ActivityIncrease();
                    myPet.ActivityIncrease();
                    myPet.StomachDecrease();
                    myPet.HitPointsDecrease();
                    myPet.HydrationDecrease();
                    if (myPet.DeathCheck())
                    {
                        Console.WriteLine("\nGAME OVER!!");
                        selectedOption = quitOption;
                        break;
                    }
                    Console.WriteLine("That was fun!!");
                    break;


                // Discipline Pet
                case 5:
                    myPet.Punish();
                    if (myPet.DeathCheck())
                    {
                        Console.WriteLine("\nGAME OVER!!");
                        selectedOption = quitOption;
                        break;
                    }
                    break;


                // Rename Pet
                case 6:
                    myPet.PetName("y");
                    break;


                // Quit Option
                case 7:
                    Console.WriteLine("Thank you for playing.");
                    break;

                default:
                    Console.WriteLine("Invalid option selected.");
                    break;
                }
            } while (selectedOption != 7);
        }