Exemplo n.º 1
0
        static void Main(string[] args)
        {
            VirtualPetShelter grovewood = new VirtualPetShelter();
            Manager           karen     = new Manager("2/10/2010", "Volunteer", "Karen", 0020, "Manager", "02/06/2008");
            Volunteer         joseph    = new Volunteer("Joseph", 200, "Volunteer", "08/17/2017", 20, "Volunteer Inc");



            bool gameOn = true;

            string[] employeeArray        = new string[] { "1. Shelter Manager", "2. Shelter Volunteer" };
            string[] managerChoiceArray   = new string[] { "1. Play", "2. Adopt", "3. Take to doctor", "4. Lay down for a Nap", "5. Exit" };
            string[] volunteerChoiceArray = new string[] { "1. Feed", "2. Give Water", "3.Play", "4. Take to doctor", "5. Lay down for a Nap", "6. Exit" };

            while (gameOn == true)
            {
                int employeeValue = 0;

                Console.WriteLine("Welcome to the Grovewood Magical Shelter! What kind of employee are you?");
                for (int i = 0; i < employeeArray.Length; i++)
                {
                    Console.WriteLine(employeeArray[i]);
                }
                employeeValue = int.Parse(Console.ReadLine());

                switch (employeeValue)
                {
                case 1:
                    bool managerMode = true;
                    while (managerMode == true)
                    {
                        Console.WriteLine("Good Morning {0}", karen.Name);
                        karen.ShopTimer(grovewood);
                        Console.WriteLine("This is the Status of Your pets");
                        foreach (var item in grovewood.PetRoster)
                        {
                            Console.WriteLine("");
                            Console.WriteLine("Name: {0}", item.Name);
                            Console.WriteLine("Hunger: {0}", item.Hunger);
                            Console.WriteLine("Boredom: {0}", item.Boredom);
                            Console.WriteLine("Tiredness: {0}", item.Tired);
                            Console.WriteLine("Sickness: {0}", item.Sickness);
                            Console.WriteLine("");
                        }

                        Console.WriteLine("What would you like to do today?");
                        for (int i = 0; i < managerChoiceArray.Length; i++)
                        {
                            Console.WriteLine(managerChoiceArray[i]);
                        }
                        int managerChoice = int.Parse(Console.ReadLine());
                        switch (managerChoice)
                        {
                        case 1:
                            karen.Play(grovewood);
                            break;

                        case 2: /*karen.Adopt();*/         //had some issues with this one
                            break;

                        case 3: karen.DoctorVisit(grovewood);
                            break;

                        case 4: karen.Sleep(grovewood);
                            break;

                        case 5: managerMode = false;
                            break;

                        default:
                            Console.WriteLine("I'm sorry, you entered an unknown choice, please try again.");
                            break;
                        }
                    }
                    break;

                case 2:
                    bool volunteerMode = true;
                    while (volunteerMode == true)
                    {
                        Console.WriteLine("Good Morning {0}", joseph.Name);
                        karen.ShopTimer(grovewood);
                        Console.WriteLine("This is the Status of Your pets");
                        foreach (var item in grovewood.PetRoster)
                        {
                            Console.WriteLine("");
                            Console.WriteLine("Name: {0}", item.Name);
                            Console.WriteLine("Hunger: {0}", item.Hunger);
                            Console.WriteLine("Boredom: {0}", item.Boredom);
                            Console.WriteLine("Tiredness: {0}", item.Tired);
                            Console.WriteLine("Sickness: {0}", item.Sickness);
                            Console.WriteLine("");
                        }

                        Console.WriteLine("What would you like to do today?");
                        for (int i = 0; i < volunteerChoiceArray.Length; i++)
                        {
                            Console.WriteLine(managerChoiceArray[i]);
                        }
                        int managerChoice = int.Parse(Console.ReadLine());
                        switch (managerChoice)
                        {
                        case 1:
                            joseph.FeedPets(grovewood);
                            foreach (var item in grovewood.PetRoster)
                            {
                                Console.WriteLine("You fed {0} their favorite meal! {1}!", item.Name, item.Diet);
                            }
                            break;

                        case 2:
                            joseph.Water(grovewood);
                            break;

                        case 3:
                            joseph.Play(grovewood);
                            break;

                        case 4:
                            joseph.DoctorVisit(grovewood);
                            break;

                        case 5:
                            joseph.Sleep(grovewood);
                            break;

                        case 6:
                            volunteerMode = false;
                            break;

                        default:
                            Console.WriteLine("I'm sorry, you entered an unknown choice, please try again.");
                            break;
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
        static void Main(string[] args)
        {
            string            exitMain  = "no";
            Manager           Louie     = new Manager(12, 17, 13, 15, true, true, false, false);
            VirtualPetShelter BrightDay = new VirtualPetShelter("Carl", "Mike", "Sarah", "Maxine", "Bob", "Peep");
            Volunteer         Nikki     = new Volunteer();


            Console.WriteLine("Welcome to Bright Day Pet Shelter. Press 1 if you are a manager. Press 2 if you are a volunteer.");
            while (exitMain == "no")
            {
                int menuResponseOne = int.Parse(Console.ReadLine());
                if (menuResponseOne == 1)
                {
                    Console.WriteLine("Manager");
                    Console.WriteLine("Select 1 to view the status of a pet. Select 2 to play with one of the pets. Select 3 to set up a pet adoption. /*Select 4 to add overtime for an employee.*/");//I commented out the last option(but it still shows) because that particular option is crashing the program, and I'm not sure why.
                    int response = int.Parse(Console.ReadLine());
                    if (response == 1)
                    {
                        Console.WriteLine("Select 1 to check hunger status. Select 2 to check thirst status. Select 3 to check sleepiness status. Select 4 to check happiness status.");
                        int statusResponse = int.Parse(Console.ReadLine());
                        if (statusResponse == 1)
                        {
                            int action;
                            Console.WriteLine(Louie.HungryStatus());
                            if (Louie.HungryStatus() == true)
                            {
                                Console.WriteLine("Your pet is hungry. Press 1 to give it food.");
                                action = int.Parse(Console.ReadLine());
                                if (action == 1)
                                {
                                    Louie.PetFeeding();
                                    Console.WriteLine("You have now given your pet food.");
                                }
                            }

                            else if (Louie.HungryStatus() == false)
                            {
                                Console.WriteLine("Your pet has enough food.");
                            }
                        }

                        else if (statusResponse == 2)
                        {
                            int action;
                            Console.WriteLine(Louie.ThirstyStatus());
                            if (Louie.ThirstyStatus() == true)
                            {
                                Console.WriteLine("Your pet is thirsty. Press 1 to give it water.");
                                action = int.Parse(Console.ReadLine());
                                if (action == 1)
                                {
                                    Louie.PetWatering();
                                    Console.WriteLine("You have now given your pet water.");
                                }
                            }

                            else if (Louie.ThirstyStatus() == false)
                            {
                                Console.WriteLine("Your pet has enough water.");
                            }
                        }

                        else if (statusResponse == 3)
                        {
                            int action;
                            Console.WriteLine(Louie.SleepyStatus());
                            if (Louie.SleepyStatus() == true)
                            {
                                Console.WriteLine("Your pet is sleepy. Press 1 to give it a nap.");
                                action = int.Parse(Console.ReadLine());
                                if (action == 1)
                                {
                                    Louie.PetSleeping();
                                    Console.WriteLine("You have now given your pet a nap.");
                                }
                            }

                            else if (Louie.SleepyStatus() == false)
                            {
                                Console.WriteLine("Your pet has enough rest.");
                            }
                        }

                        else if (statusResponse == 4)
                        {
                            int action;
                            Console.WriteLine(Louie.HappyStatus());
                            if (Louie.HappyStatus() == true)
                            {
                                Console.WriteLine("Your pet is sad. Press 1 to play with it.");
                                action = int.Parse(Console.ReadLine());
                                if (action == 1)
                                {
                                    Louie.PetPlaying();
                                    Console.WriteLine("You have now played with your pet.");
                                }
                            }

                            else if (Louie.HappyStatus() == false)
                            {
                                Console.WriteLine("Your pet is happy!");
                            }
                        }
                    }

                    else if (response == 2)
                    {
                        Louie.PetPlaying();
                        Console.WriteLine("You have played with your pet.");
                    }

                    else if (response == 3)
                    {
                        Louie.Adoption();//I created a method, but I am not sure how to link the lists to it.
                    }

                    //else if (response == 4)//I have this section commented out, because I ran it, and it crashed, and I'm not sure why.
                    //{
                    //    Louie.PunchIn();
                    //    Console.WriteLine("You have added overtime for an employee.");
                    //}
                }

                if (menuResponseOne == 2)
                {
                    Console.WriteLine("Volunteer");
                    Console.WriteLine("Select 1 to check the status of a pet. Select 2 to play with one of the pets. /*Select 3 to sign up for overtime.*/");
                    int response = int.Parse(Console.ReadLine());
                    if (response == 1)
                    {
                        Console.WriteLine("Select 1 to check hunger status. Select 2 to check thirst status. Select 3 to check sleepiness status. Select 4 to check happiness status.");
                        int statusResponse = int.Parse(Console.ReadLine());
                        if (statusResponse == 1)
                        {
                            int action;
                            Console.WriteLine(Nikki.HungryStatus());
                            if (Nikki.HungryStatus() == true)
                            {
                                Console.WriteLine("Your pet is hungry. Press 1 to give it food.");
                                action = int.Parse(Console.ReadLine());
                                if (action == 1)
                                {
                                    Nikki.PetFeeding();
                                    Console.WriteLine("You have now given your pet food.");
                                }
                            }

                            else if (Nikki.HungryStatus() == false)
                            {
                                Console.WriteLine("Your pet has enough food.");
                            }


                            else if (statusResponse == 2)
                            {
                                Console.WriteLine(Nikki.ThirstyStatus());
                                if (Nikki.ThirstyStatus() == true)
                                {
                                    Console.WriteLine("Your pet is thirsty. Press 1 to give it water.");
                                    action = int.Parse(Console.ReadLine());
                                    if (action == 1)
                                    {
                                        Nikki.PetWatering();
                                        Console.WriteLine("You have now given your pet water.");
                                    }
                                }

                                else if (Nikki.ThirstyStatus() == false)
                                {
                                    Console.WriteLine("Your pet has enough water.");
                                }
                            }

                            else if (statusResponse == 3)
                            {
                                Console.WriteLine(Louie.SleepyStatus());
                                if (Nikki.SleepyStatus() == true)
                                {
                                    Console.WriteLine("Your pet is sleepy. Press 1 to give it a nap.");
                                    action = int.Parse(Console.ReadLine());
                                    if (action == 1)
                                    {
                                        Nikki.PetSleeping();
                                        Console.WriteLine("You have now given your pet a nap.");
                                    }
                                }

                                else if (Nikki.SleepyStatus() == false)
                                {
                                    Console.WriteLine("Your pet has enough rest.");
                                }
                            }

                            else if (statusResponse == 4)
                            {
                                Console.WriteLine(Louie.HappyStatus());
                                if (Nikki.HappyStatus() == true)
                                {
                                    Console.WriteLine("Your pet is sad. Press 1 to play with it.");
                                    action = int.Parse(Console.ReadLine());
                                    if (action == 1)
                                    {
                                        Nikki.PetPlaying();
                                        Console.WriteLine("You have now played with your pet.");
                                    }
                                }

                                else if (Nikki.HappyStatus() == false)
                                {
                                    Console.WriteLine("Your pet is happy!");
                                }
                            }
                        }
                    }


                    else if (response == 2)
                    {
                        Nikki.PetPlaying();
                        Console.WriteLine("You have played with your pet.");
                    }

                    //else if (response == 3)
                    //{
                    //    Nikki.PunchIn();
                    //    Console.WriteLine("You have signed up for overtime.");
                    //}
                }
            }
            Console.WriteLine("Thank you for visiting Bright Day Pet Shelter.");
            exitMain = "yes";
        }
        static void Main(string[] args)
        {
            //DECLARED MISC VARIABLES FOR NEATNESS SAKE
            ConsoleKeyInfo keyselect;
            bool           quit = true;
            string         relay;



            //declaring class instances for the pets
            VirtualPetShelter shelter   = new VirtualPetShelter("Funny Farm");
            Big_Dog           carl      = new Big_Dog("carl");
            Big_Dog           hardee    = new Big_Dog("hardee");
            SmallDog          carlsjr   = new SmallDog("carlsjr");
            SmallDog          hardeesjr = new SmallDog("hardeesjr");

            shelter.PetAdd(carl); // adding them to the list in VirtualPetShelter as required
            shelter.PetAdd(hardee);
            shelter.PetAdd(carlsjr);
            shelter.PetAdd(hardeesjr);



            //UI START
            // TITLE CARD
            Console.WriteLine("Welcome to the  Virtual Pet Shelter Control Console TM. \n Press any key to begin.");
            Console.ReadKey();
            do
            {
                Console.Clear();
                Console.WriteLine("Which Type of user are you? \n [1] VOLUNTEER \n [2] MANAGER \n SELECT AN OPTION OR PRESS Q TO QUIT");

                keyselect = Console.ReadKey();

                switch (keyselect.KeyChar)
                {
// VOLUNTEER CODE
                case '1':
                    Console.Clear();
                    Console.WriteLine("What is your Name?");
                    relay = Console.ReadLine();
                    Console.WriteLine("What is your specialty \n [1] Feeding \n [2] Watering \n [3] Entertaining");
                    keyselect = Console.ReadKey();
                    Volunteer volun = new Volunteer(relay, keyselect.KeyChar);     // declaring volunteer class with name and expertise input
                    shelter.ShelterEmployee.Add(volun);


                    do
// prints out the pet status
                    {
                        Console.Clear();
                        Console.WriteLine("Welcome {0} the current pets availible are:", volun.Name);
                        Console.WriteLine("Name:   HungerLVL    ThirstLVL   BoredomLVL");
                        foreach (VirtualPet pet in shelter.ShelterPets)     // prints the list of pets and their status
                        {
                            Console.Write(pet.Name);
                            for (int i = 0; i < 9 - pet.Name.Length; i++)     // this loop makes the ui look cool and spaced evenly while in double digits at least
                            {
                                Console.Write(" ");
                            }

                            Console.WriteLine("     {0}            {1}            {2}", pet.Hunger, pet.Thirst, pet.Boredom);
                        }

// ACTIONS CHOICE FOR VOLUNTEER
                        Console.WriteLine("\n \n \n What action would you like to partake");
                        Console.WriteLine(" [1] Feed All Pets \n [2] Water All Pets \n [3] Play With a Pet \n [4] Go back");
                        keyselect = Console.ReadKey();
                        switch (keyselect.KeyChar)
                        {
                        case '1':         // feed
                            volun.Feed(shelter);
                            break;

                        case '2':         // water
                            volun.Water(shelter);
                            break;

                        case '3':         // play
                            do
                            {
                                int counter = 1;
                                Console.WriteLine("Which pet do you want to play with?");
                                foreach (VirtualPet pet in shelter.ShelterPets)         // loop to display names and number to select
                                {
                                    Console.WriteLine(" [{0}] {1}", counter, pet.Name);
                                    counter++;
                                }
                                keyselect = Console.ReadKey();         // input for play select
                            }while (KeyCheck(keyselect.KeyChar));
                            volun.Play(shelter, (int)Char.GetNumericValue(keyselect.KeyChar));
                            break;         // break for play

                        case '4':
                            quit = false;
                            break;
                        }
                    } while (quit); quit = true;
                    Console.WriteLine("test");
                    break;     // volunteer break



// MANAGER CODE
                case '2':
                    Manager manager = new Manager("Darren");
                    shelter.ShelterEmployee.Add(manager);
                    // PET STATUS DISPLAY
                    do
                    {
                        Console.Clear();
                        Console.WriteLine("Welcome Manager the current pets availible are:");
                        Console.WriteLine("Name:   HungerLVL    ThirstLVL   BoredomLVL");
                        foreach (VirtualPet pet in shelter.ShelterPets)     // prints the list of pets and their status
                        {
                            Console.Write(pet.Name);
                            for (int i = 0; i < 9 - pet.Name.Length; i++)     // this loop makes the ui look cool and spaced evenly while in double digits at least
                            {
                                Console.Write(" ");
                            }
                            Console.WriteLine("     {0}            {1}            {2}", pet.Hunger, pet.Thirst, pet.Boredom);
                        }
                        Console.WriteLine("\n \n \n What action would you like to partake");
                        Console.WriteLine(" [1] Feed All Pets \n [2] Water All Pets \n [3] Play With all Pets \n [4] Adopt \n [5] Go Back");
                        keyselect = Console.ReadKey();
                        switch (keyselect.KeyChar)
                        {
                        case '1':
                            manager.Feed(shelter);
                            break;

                        case '2':
                            manager.Water(shelter);
                            break;

                        case '3':
                            manager.Play(shelter, 0);
                            break;

                        case '4':
                            int counter = 0;
                            Console.WriteLine("Which pet would you like to adopt out? \n Current Pets Availible:");
                            foreach (VirtualPet pet in shelter.ShelterPets)
                            {
                                counter++;
                                Console.WriteLine("[{0}] {1} - {2}", counter, pet.Name, pet.Description);
                            }
                            Console.WriteLine("enter selection number and press enter");
                            manager.Adopt(shelter, int.Parse(Console.ReadLine()));
                            break;

                        case '5':
                            quit = false;
                            break;

                        default:
                            break;
                        }
                    }while (quit); quit = true;
                    break;  // MANAGER BREAK

                case 'q':   //QUIT CODE
                    quit = false;
                    break;

                default:     // nothing
                    break;
                }
            }while (quit);
        }   // main