예제 #1
0
        static void Main(string[] args)
        {
            Random random = new Random();

            //organic pet
            int startHunger = random.Next(50, 70);
            int startEnergy = random.Next(50, 60);
            int startHealth = random.Next(30, 50);

            //robot pet
            int startGasLevel = random.Next(10, 50);
            int startOilLevel = random.Next(30, 60);
            int startCharger  = random.Next(5, 20);

            Pet pet = new Pet();

            OrganicPet organicPet = new OrganicPet();

            organicPet.Health = startHealth;
            organicPet.Hunger = startHunger;
            organicPet.Energy = startEnergy;

            RobotPet robotPet = new RobotPet();

            robotPet.GasLevel = startGasLevel;
            robotPet.OilLevel = startOilLevel;
            robotPet.Charger  = startCharger;


            bool VirtualPet = true;

            do
            {
                organicPet.Tick();
                Console.WriteLine("Welcome to Pixel Pet!\n");
                Console.WriteLine("What do you want to do?");
                Console.WriteLine("1. Pick your species of pet");
                Console.WriteLine("2. Name your pet!");
                Console.WriteLine("3. Feed your pet");
                Console.WriteLine("4. Play with your pet");
                Console.WriteLine("5. Take pet to the doctor");
                Console.WriteLine("6. Visit the pet shelter!");
                Console.WriteLine("7. Check the status of you pet");
                Console.WriteLine("8. Exit game.");

                string userChoice = Console.ReadLine().ToLower();
                Console.Clear();

                switch (userChoice)
                {
                case "1":
                    Console.WriteLine("What species of animal would you like?");
                    string speciesOfPet = Console.ReadLine();
                    pet.SetSpecies(speciesOfPet);

                    Console.WriteLine($"The species of your animal is: {pet.Species}\n");
                    break;

                case "2":
                    Console.WriteLine("What would you like to name your pet?");
                    string nameOfPet = Console.ReadLine();
                    pet.SetName(nameOfPet);

                    Console.WriteLine("\n");

                    Console.WriteLine($"Congratulations! \nThe name of your pet is: {pet.Name}\n");
                    break;

                case "3":
                    organicPet.Feed();
                    Console.WriteLine($"Would you like to feed {pet.Name}?");
                    Console.WriteLine($"{pet.Name} hunger levels are:{organicPet.Hunger}\n");
                    break;

                case "4":
                    organicPet.Play();
                    Console.WriteLine($"Would you like to play with {pet.Name}?");
                    Console.WriteLine($"{pet.Name} boredom levels are:{organicPet.Energy}\n");
                    break;

                case "5":
                    organicPet.SeeDoctor();
                    Console.WriteLine($"Would you like to take care of {pet.Name}?");
                    Console.WriteLine($"{pet.Name} Health levels are:{organicPet.Health}\n");
                    break;

                case "6":
                    Console.WriteLine("Welcome to the Pixel Pet Shelter!!");
                    break;

                case "7":
                    Console.WriteLine("Check overall status of pet:\n");
                    Console.WriteLine($"The name of your pet is {pet.Name} with a species type of {pet.Species}");
                    Console.WriteLine($"Hunger: {organicPet.Hunger}");
                    Console.WriteLine($"Boredom: {organicPet.Energy}");
                    Console.WriteLine($"Health: {organicPet.Health}");
                    break;

                case "8":
                    VirtualPet = false;
                    Console.WriteLine("Good bye!");
                    break;

                default:
                    Console.WriteLine("Please enter a valid number.");
                    break;
                }

                Console.WriteLine("Return to main menu\n");
                Console.ReadKey();
                Console.Clear();
            } while (VirtualPet);
        }
예제 #2
0
        static void Main(string[] args)
        {
            Pet     newPet     = new Pet();
            Shelter petShelter = new Shelter();

            petShelter.AddPet(newPet);
            bool keepThinking = true;

            while (keepThinking)
            {
                Console.WriteLine("Hi and Welcome to the Perrysburg Pet Shelter!");
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1. I'm Bringing in a New Organic Pet");
                Console.WriteLine("2. I'm Brining in a New Mechcanical Pet");
                Console.WriteLine("3. Feed all of the Pets");
                Console.WriteLine("4. Play with all of the Pets");
                Console.WriteLine("5. Play with a Single Pet");
                Console.WriteLine("6. Adopt a Pet");
                Console.WriteLine("7. Leave the Shelter");
                //Console.Clear();
                string menuChoice = Console.ReadLine().ToLower();

                switch (menuChoice)
                {
                case "1":
                    newPet = new Pet();
                    Console.WriteLine("What is your organic pet's name?");
                    string name = Console.ReadLine();
                    newPet.SetName(name);

                    Console.WriteLine("What species is your organic pet? (Example: tiger, dog, fish");
                    string species = Console.ReadLine();
                    newPet.SetSpecies(species);
                    petShelter.AddPet(newPet);
                    petShelter.PrintAllPets();
                    Console.WriteLine("\n");
                    break;
                    //case "2":
                    Console.WriteLine("What is your mechcanical pet's name?");
                    string name = Console.ReadLine();
                    newPet.SetName(name);

                    Console.WriteLine("What type is your pet? (Example: Robot or Cyborg");
                    string species = Console.ReadLine();
                    newPet.SetSpecies(species);
                    petShelter.AddPet(newPet);
                    petShelter.PrintAllPets();
                    Console.WriteLine("\n");
                    break;

                case "3":
                    petShelter.PrintAllPets();
                    petShelter.FeedAll();
                    Console.WriteLine("You fed the pets!");
                    Console.WriteLine("\n");
                    break;

                case "4":
                    petShelter.PrintAllPets();
                    petShelter.PlayAll();
                    Console.WriteLine("You played with the pets!");
                    Console.WriteLine("\n");
                    break;

                case "5":
                    petShelter.PrintAllPets();
                    Console.WriteLine("Which pet would you like to play with?");
                    string petToPlay = Console.ReadLine();
                    newPet = petShelter.PetSelect(petToPlay);
                    petShelter.Play(newPet);
                    Console.WriteLine($"You played with {newPet.GetName()}!");
                    Console.WriteLine("\n");
                    break;

                case "6":
                    petShelter.PrintAllPets();
                    Console.WriteLine("Which pet would you like to adopt?");
                    string petToAdopt = Console.ReadLine();
                    newPet = petShelter.PetSelect(petToAdopt);
                    petShelter.RemovePet(newPet);
                    Console.WriteLine($"You gave {newPet.GetName()} a good home!");
                    Console.WriteLine("\n");
                    break;

                case "7":
                    keepThinking = false;
                    Console.WriteLine("Good Bye! Thanks for Visiting!");
                    break;

                default:
                    break;
                }
            }
        }
        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)
        {
            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);
        }