示例#1
0
        static void Main(string[] args)
        {
            VirtualPet elsie = new VirtualPet("Elsie", 1, "Grey");
            string     selection;

            Console.WriteLine("Congratulations on your new pet elephant! You've decided to name her Elsie.");
            ElsieArt();
            Console.WriteLine(elsie.Stats());
            Console.WriteLine("\n");
            Pause();

            do
            {
                Console.WriteLine("What would you like to do with Elsie?");
                Menu();
                selection = Console.ReadLine().Trim();

                if (selection == "1")
                {
                    elsie.Eat();
                    Pause();
                }
                else if (selection == "2")
                {
                    elsie.Drink();
                    Pause();
                }
                else if (selection == "3")
                {
                    elsie.Play();
                    Pause();
                }
                else if (selection == "4")
                {
                    elsie.Sleep();
                    Pause();
                }
                else if (selection == "5")
                {
                    Console.WriteLine("Elsie looks sad and goes to play by herself.");
                    Pause();
                }
                else
                {
                    if (selection != "6")
                    {
                        Console.WriteLine("Please choose something to do with Elsie!");
                    }
                }
            }while (selection != "6");

            {
                Console.WriteLine("Thanks for playing!");
                Environment.Exit(0);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            // User Interface
            VirtualPet cat = new VirtualPet(6, 4, 4);

            Console.WriteLine("Welcome to your VirtualPet! Please type Start to begin.");
            Console.Write("> ");
            string userResponse = Console.ReadLine().ToLower();

            while (userResponse.Equals("start"))
            {
                Console.WriteLine();
                Console.WriteLine("CURRENT PET STATUS");
                Console.WriteLine("Sleep level: {0}", cat.Sleep);
                Console.WriteLine("Hunger level: {0}", cat.Hunger);
                Console.WriteLine("Boredom level: {0}", cat.Boredom);
                Console.WriteLine();
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1: Let your pet take a nap.");
                Console.WriteLine("2: Feed your pet.");
                Console.WriteLine("3: Play with your pet.");
                Console.WriteLine("4: Leave your pet at home over a long weekend.");
                Console.WriteLine("5: Don't do anything.");
                Console.WriteLine();

                if (cat.EnoughSleep) // Checks for sleep
                {
                    Console.WriteLine("WARNING! Your pet is getting drowsy. Enter 1 to let your pet take a nap.");
                }
                if (cat.EnoughFood) // Checks for hunger
                {
                    Console.WriteLine("WARNING! Your pet needs to eat! Enter 2 to feed your pet.");
                }
                if (cat.EnoughPlay) // Checks for boredom
                {
                    Console.WriteLine("WARNING! Your pet is getting antsy and needs to play! Enter 3 to play with your pet.");
                }

                Console.Write("Enter 1, 2, 3, 4 or 5: > "); // Menu prompt

                // Menu functionality (Accept userChoice and call appropriate method with selection of 1, 2 or 3)
                int userChoice = int.Parse(Console.ReadLine());
                switch (userChoice)
                {
                case 1:
                    cat.Nap();
                    Console.WriteLine("Your pet took a nap.");
                    break;

                case 2:
                    cat.Eat();
                    Console.WriteLine("You fed your pet.");
                    break;

                case 3:
                    cat.Play();
                    Console.WriteLine("You played with your pet.");
                    break;

                case 4:
                    cat.Vacation();
                    Console.WriteLine("You left your pet alone over a long weekend.");
                    break;

                case 5:
                    break;
                }

                cat.Tick(); // Call Tick() method with every display of menu
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            VirtualPet dragonPet = new VirtualPet();
            string     option;

            Console.WriteLine("Welcome to Dragonland");

            int typeOfDragon;

            Console.WriteLine("What kind of Dragon do you want to be?");
            Console.WriteLine("Press 1 for Dragonite, \nPress 2 for Black dragon, \nPress 3 for White dragon,\nor Press 4 for Pink dragon");
            typeOfDragon = int.Parse(Console.ReadLine());

            if (typeOfDragon == 1)
            {
                Console.WriteLine("Dragonite");
            }
            else if (typeOfDragon == 2)
            {
                Console.WriteLine("Black Dragon");
            }
            else if (typeOfDragon == 3)
            {
                Console.WriteLine("White Dragon");
            }
            else if (typeOfDragon == 4)
            {
                Console.WriteLine("Pink Dragon");
            }
            else
            {
                Console.WriteLine("Gumpy the Dragon");
            }



            do
            {
                dragonPet.Stats();
                Console.WriteLine("What do you want to do? Earn Money, Drink soda, Eat, or Sleep?");
                Console.WriteLine("Press 1 to earn money, 2 to drink soda, 3 to eat, or 4 to sleep");
                string answer = Console.ReadLine();

                if (answer == "1")
                {
                    dragonPet.Raise();
                }

                else if (answer == "2")
                {
                    dragonPet.DrinkSoda();
                }

                else if (answer == "3")
                {
                    dragonPet.Eat();
                }

                else if (answer == "4")
                {
                    dragonPet.Sleep();
                }

                else
                {
                    dragonPet.DrinkSoda();
                }

                dragonPet.Stats();

                Console.WriteLine("Do you want to go again? \nType yes to go again!");
                option = Console.ReadLine();
                option = option.ToUpper();
            } while (option == "Yes");
            Console.ReadLine();
        }
示例#4
0
        static void Main(string[] args)
        {
            VirtualPet porkchop = new VirtualPet("Porkchop the Dog", 5, 30, 25, 15, 10, 0);

            Console.WriteLine(@" _   _");
            Console.WriteLine(@"/(. .)\    )");
            Console.WriteLine(@"  (*)____/|");
            Console.WriteLine(@"  /       |");
            Console.WriteLine(@" /   |--\ |");
            Console.WriteLine(@"(_)(_)  (_)");

            Console.WriteLine(porkchop.Name);
            Console.WriteLine();

            Console.WriteLine("Hunger: {0}", porkchop.Hunger);
            Console.WriteLine("Thirst: {0}", porkchop.Thirst);
            Console.WriteLine("Sleep: {0}", porkchop.Sleep);
            Console.WriteLine("Potty: {0}", porkchop.Potty);
            Console.WriteLine("Boredom: {0}", porkchop.Boredom);
            Console.WriteLine("Sickness: {0}", porkchop.Sickness);

            Console.WriteLine("\nWhat do you want Porkchop to do?\n");
            Console.WriteLine("1. Eat");
            Console.WriteLine("2. Drink");
            Console.WriteLine("3. Take Nap");
            Console.WriteLine("4. Go Potty");
            Console.WriteLine("5. Play");
            Console.WriteLine("6. See Doctor");
            Console.WriteLine("7. Do Nothing\n");

            Console.Write("> ");
            int response = int.Parse(Console.ReadLine());

            while (response != 7)
            {
                if (response <= 0 || response >= 8)
                {
                    Console.WriteLine("\nPlease choose a valid menu option 1 through 7.");
                }

                switch (response)
                {
                case 1:
                    porkchop.Eat();
                    porkchop.Tick();
                    Console.WriteLine("\nPorkchop ate food.\n");
                    Console.WriteLine("Hunger: {0}", porkchop.Hunger);
                    Console.WriteLine("Thirst: {0}", porkchop.Thirst);
                    Console.WriteLine("Sleep: {0}", porkchop.Sleep);
                    Console.WriteLine("Potty: {0}", porkchop.Potty);
                    Console.WriteLine("Boredom: {0}", porkchop.Boredom);
                    Console.WriteLine("Sickness: {0}", porkchop.Sickness);
                    break;

                case 2:
                    porkchop.Drink();
                    porkchop.Tick();
                    Console.WriteLine("\nPorkchop drank water.\n");
                    Console.WriteLine("Hunger: {0}", porkchop.Hunger);
                    Console.WriteLine("Thirst: {0}", porkchop.Thirst);
                    Console.WriteLine("Sleep: {0}", porkchop.Sleep);
                    Console.WriteLine("Potty: {0}", porkchop.Potty);
                    Console.WriteLine("Boredom: {0}", porkchop.Boredom);
                    Console.WriteLine("Sickness: {0}", porkchop.Sickness);
                    break;

                case 3:
                    porkchop.TakeNap();
                    porkchop.Tick();
                    Console.WriteLine("\nPorkchop took a nap.\n");
                    Console.WriteLine("Hunger: {0}", porkchop.Hunger);
                    Console.WriteLine("Thirst: {0}", porkchop.Thirst);
                    Console.WriteLine("Sleep: {0}", porkchop.Sleep);
                    Console.WriteLine("Potty: {0}", porkchop.Potty);
                    Console.WriteLine("Boredom: {0}", porkchop.Boredom);
                    Console.WriteLine("Sickness: {0}", porkchop.Sickness);
                    break;

                case 4:
                    porkchop.GoPotty();
                    porkchop.Tick();
                    Console.WriteLine("\nPorkchop went potty.\n");
                    Console.WriteLine("Hunger: {0}", porkchop.Hunger);
                    Console.WriteLine("Thirst: {0}", porkchop.Thirst);
                    Console.WriteLine("Sleep: {0}", porkchop.Sleep);
                    Console.WriteLine("Potty: {0}", porkchop.Potty);
                    Console.WriteLine("Boredom: {0}", porkchop.Boredom);
                    Console.WriteLine("Sickness: {0}", porkchop.Sickness);
                    break;

                case 5:
                    porkchop.Play();
                    porkchop.Tick();
                    Console.WriteLine("\nPorkchop played fetch.\n");
                    Console.WriteLine("Hunger: {0}", porkchop.Hunger);
                    Console.WriteLine("Thirst: {0}", porkchop.Thirst);
                    Console.WriteLine("Sleep: {0}", porkchop.Sleep);
                    Console.WriteLine("Potty: {0}", porkchop.Potty);
                    Console.WriteLine("Boredom: {0}", porkchop.Boredom);
                    Console.WriteLine("Sickness: {0}", porkchop.Sickness);
                    break;

                case 6:
                    porkchop.SeeDoctor();
                    porkchop.Tick();
                    Console.WriteLine("\nPorkchop went to the doctor.\n");
                    Console.WriteLine("Hunger: {0}", porkchop.Hunger);
                    Console.WriteLine("Thirst: {0}", porkchop.Thirst);
                    Console.WriteLine("Sleep: {0}", porkchop.Sleep);
                    Console.WriteLine("Potty: {0}", porkchop.Potty);
                    Console.WriteLine("Boredom: {0}", porkchop.Boredom);
                    Console.WriteLine("Sickness: {0}", porkchop.Sickness);
                    break;
                } // end switch case

                Console.WriteLine("\nWhat do you want Porkchop to do?\n");
                Console.WriteLine("1. Eat");
                Console.WriteLine("2. Drink");
                Console.WriteLine("3. Take Nap");
                Console.WriteLine("4. Go Potty");
                Console.WriteLine("5. Play");
                Console.WriteLine("6. See Doctor");
                Console.WriteLine("7. Do Nothing\n");

                Console.Write("> ");
                response = int.Parse(Console.ReadLine());
            } // end while loop

            if (response == 7)
            {
                Console.WriteLine("Please come back and check on Porkchop again soon!");
            }
        } // end Main method
示例#5
0
        static void Main(string[] args)
        {
            string food  = string.Empty;
            string water = string.Empty;
            string play  = string.Empty;

            VirtualPet Godzooky = new VirtualPet();



            Console.WriteLine("Welcome to Michael's VirtualPet Project");
            Console.WriteLine(" Hi, I'm Godzilla's kid, {0} ", Godzooky.name, "lets have fun");

            //public static int TickCount
            {
                int result = Environment.TickCount & Int32.MaxValue;
                Console.WriteLine("TickCount: {0}", result);
            }
            Console.WriteLine(" choose 0 Pet Option, it will pause the Virtual Pet ");
            Console.WriteLine(" choose 1 Pet Option, it will feed {0} ", Godzooky.Name);
            Console.WriteLine(" choose 2 Pet Option, it will give {0} some water", Godzooky.Name);
            Console.WriteLine(" choose 3 Pet Option,{0} will talk to you", Godzooky.Name);
            Console.WriteLine(" choose 4 Pet Option, you can play with {0} ", Godzooky.Name);
            Console.WriteLine(" choose 5 Pet Option, you can quit the program ");
            Console.WriteLine(" TYPE your Pet Option as a number 0, 1, 2, 3, 4 or, 5 ");
            int petOptions = int.Parse(Console.ReadLine());


            switch (petOptions)
            {
            case 0:
                Console.WriteLine("OK, I'm gonna take a nap ");
                Thread.Sleep(0);
                break;

            case 1:
                Console.WriteLine("You fed {0} ", Godzooky.Name);
                Godzooky.Eat(food);
                break;

            case 2:
                Console.WriteLine(Godzooky.Name, "{0} drank some water ");
                Godzooky.Drink(water);
                break;

            case 3:
                Console.WriteLine(Godzooky.Name, " {0}spoke ");
                Godzooky.Speak();
                break;

            case 4:
                Console.WriteLine(" You played with {0} ", Godzooky.Name);
                Godzooky.Boredom(play);
                break;

            case 5:
                Console.WriteLine(" You're gonna miss out on a lot of fun, goodbye ");
                Environment.Exit(0);
                break;

            default:

                Console.WriteLine(" Invalid selection ");
                Console.WriteLine(" Please choose Pet Option 0, 1, 2, 3, 4, or, 5 ");
                break;
            }
        }
示例#6
0
        static void Main(string[] args)
        {
            //This section sets the storyline up for the user
            Console.WriteLine("Welcome to Dragon Hatcher!");
            Console.WriteLine("The interactive pet game were you hatch and raise your very own dragon!");
            Console.WriteLine("*If you wish to quit or restart the game type \"Quit\" or \"Restart\" when prompted.");
            Console.WriteLine("Let's Start!");

            Enter();//method to allow user to promt the next part of the game by pressing enter

            Console.WriteLine("We are at the Dragon Egg Store.");
            int bank = Bank();                                                                //randomized amount of money

            Console.WriteLine("\nYou have randomly been given $" + bank + " in the bank.\n"); //generates a random amount of money
            //Egg options menu
            Console.WriteLine("Please select which egg you want from the options below.\n(enter a number 1-5 or type  \"Quit\" or \"Restart\")");
            Console.WriteLine("1. Blue Egg for $50");
            Console.WriteLine("2. Purple Egg for $100");
            Console.WriteLine("3. Green Egg for $110");
            Console.WriteLine("4. White Egg for $150");
            Console.WriteLine("5. Gold Egg for $200");

            Console.Write("\nYour number is: \n");
            string option = Console.ReadLine(); //users input

            RestartorQuit(option);              //quit or restart method
            bool tester = false;

            while (!tester)
            {
                if (option == "1" || option == "2" || option == "3" || option == "4" || option == "5")
                {
                    tester = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Please enter a valid number 1-5. Try Again!");
                    option = Console.ReadLine();
                }
            }

            bool done = false;    //var that breaks the loop

            //Below is a switch case nested in a while loop that prints what egg they choose based on available bank (using if statement).
            while (!done)
            {
                switch (option)
                {
                case "1":
                    if (bank <= 300)
                    {
                        Console.WriteLine("\nYou selected: Blue Egg for $50!");
                        done = true;
                    }
                    else
                    {
                        Console.WriteLine("\nYou can't afford this Egg, try again!");
                        Console.Write("Your number is: ");
                        option = Console.ReadLine();
                    }
                    break;

                case "2":
                    if (bank >= 100)
                    {
                        Console.WriteLine("\nYou selected: Purple Egg for $100!");
                        done = true;
                    }
                    else
                    {
                        Console.WriteLine("\nYou can't afford this Egg, try again!");
                        Console.Write("Your number is: ");
                        option = Console.ReadLine();
                    }
                    break;

                case "3":
                    if (bank >= 110)
                    {
                        Console.WriteLine("\nYou selected: Green Egg for $110!");
                        done = true;
                    }
                    else
                    {
                        Console.WriteLine("\nYou can't afford this Egg, try again!");
                        Console.Write("Your number is: ");
                        option = Console.ReadLine();
                    }
                    break;

                case "4":
                    if (bank >= 150)
                    {
                        Console.WriteLine("\nYou selected: White Egg for $150!");
                        done = true;
                    }
                    else
                    {
                        Console.WriteLine("\nYou can't afford this Egg, try again!");
                        Console.Write("Your number is: ");
                        option = Console.ReadLine();
                    }
                    break;

                case "5":
                    if (bank >= 200)
                    {
                        Console.WriteLine("\nYou selected: Gold Egg for $200!");
                        done = true;
                    }
                    else
                    {
                        Console.WriteLine("\nYou can't afford this Egg, try again!");
                        Console.Write("Your number is: ");
                        option = Console.ReadLine();
                    }
                    break;

                default:
                    break;
                }
            }
            //end of While/Switch

            //Storyline continued...
            Console.WriteLine("You are now the proud owner of a dragon egg!");
            Enter();

            //hatching egg
            Console.Write("A week has past and your egg is ready to Hatch. You must rub the egg three times");
            Console.Write("to hatch it. Type \"Rub\" to start hatching your dragon!\n(you can also quit or restart here)\n ");

            string hatch = Console.ReadLine();

            RestartorQuit(hatch);
            bool counter = false;

            //uses Hatch method, checks first input only
            do
            {
                if (hatch.Equals("rub", StringComparison.CurrentCultureIgnoreCase))
                {
                    Hatch(hatch);//method to hatch egg by taking user input three times
                    counter = false;
                    break;
                }
                else
                {
                    Console.WriteLine("Careful! You can only rub your dragon in order to hatch it. Try Again!");
                    hatch = Console.ReadLine();
                }
            }while (!counter);

            Console.WriteLine("\nCrack!! Congrats, you have hatched your new baby dragon!");
            Enter();
            Console.WriteLine("Type \"Generate\" to see what color and gender your dragon is!");
            string generate = Console.ReadLine();

            GenerateDragon(generate);//method that randomly generates a color and gender combo

            Console.WriteLine("\nNow it is time to start taking care of your new pet Dragon!");
            Console.WriteLine("Let's start by NAMING your pet! Enter the name you want for your dragon below:\n(you can also quit or restart here) ");

            //Below I am instantiating the new pet object and assigning it default pet type
            VirtualPet pet = new VirtualPet("Dragon");

            pet.GetName = Console.ReadLine();//naming and storing the name in GetName property
            RestartorQuit(pet.GetName);
            Console.WriteLine("You have named your dragon " + pet.GetName + "! Great Name!");
            Enter();

            Console.WriteLine("Now you can interact with " + pet.GetName + "! \nWe will choose from a menu of options in order to raise " + pet.GetName + ". Let's Go!!");

            //BEGINNING OF THE LOOP FOR THE INTERACTION MENU!

            bool test = false; //var that breaks do while loop

            do
            {
                int track = pet.Track(); //track method, stores value back into track each time loop runs. Acts as a counter
                pet.PrintTrack();        //prints Dragons "age" as he "grows" based on the tracker

                //Breaks the loop if user does one of the following:
                if (pet.Hunger < 0)
                {
                    Console.WriteLine(pet.GetName + "'s Hunger went below zero!");
                    test = false;
                    break;
                }
                if (pet.Food < 0)
                {
                    Console.WriteLine(pet.GetName + "'s Food Stock went below zero!");
                    test = false;
                    break;
                }
                if (pet.Energy < 0)
                {
                    Console.WriteLine(pet.GetName + "'s Energy went below zero!");
                    test = false;
                    break;
                }
                if (track == 15)
                {
                    test = false;
                    break;
                }

                //prompts user to start menu again
                Console.WriteLine("(Hit Enter for Interactive Menu Options)");

                RestartorQuit(Console.ReadLine());
                pet.MenuDisplayNameandDragon();                                      //always prints out dragons name and the words The Dragon
                Console.WriteLine("Please select which interaction you want from the options below\n(enter a number 1 - 6 or type \"Quit\" or \"Restart\" here): ");
                Console.WriteLine("1.PLAY\n2.TRAIN\n3.HUNT\n4.EAT\n5.FLY\n6.SLEEP"); //menu of possible interactions

                string selector = Console.ReadLine();                                //user input as string

                RestartorQuit(selector);                                             //allows user to restart or quit at this point

                pet.Selector = int.Parse(selector);                                  //takes users input a gives it to switch case as int

                //switch case to activate the interaction methods in virtualpet class, based on user selection
                switch (pet.Selector)
                {
                case 1:
                    pet.Play();
                    break;

                case 2:
                    pet.Train();
                    break;

                case 3:
                    pet.Hunt();
                    break;

                case 4:
                    pet.Eat();
                    break;

                case 5:
                    pet.Fly();
                    break;

                case 6:
                    pet.SleepMethod();
                    break;

                default:
                    break;
                }
            } while (!test);

            //what happens if loop breaks, game over.
            Console.WriteLine("The game is over :( .\nHit any key to quit or \"Restart\" to continue.");
            RestartorQuit(Console.ReadLine());
        }