Ejemplo n.º 1
0
        static public string checkForHallOfFameAward() //method to check for award won to display to user
        {
            RecordBook seriesAwards = new RecordBook(6, "All Time Great Hall of Famer");
            RecordBook gameAwards   = new RecordBook(2, "Gamer Hall of Fame Award");

            string awardToReturn = null;                           //if this reamains null (no award won) the calliing method should not post mention of awards

            if (totalSeriesWon >= seriesAwards.winsNeededForAward) //decides if user won enough series to win an award
            {
                awardToReturn = "All Time Great Hall of Famer";
                return(awardToReturn);
            }
            else
            {
                if (totalGamesWon >= gameAwards.winsNeededForAward) //decides if user won enough games to win award
                {
                    awardToReturn = "Great Player Award";
                    return(awardToReturn);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 2
0
        static public void goodbye()
        {
            string finalStatLine = RecordBook.getFinalStatLine(); //gets games, series won from RecordBook

            Console.WriteLine(finalStatLine);
            string award = RecordBook.checkForHallOfFameAward(); //checks for an award

            if (award != null)                                   //displays the award only if award was won
            {
                Console.WriteLine("Congrats! You won the " + award + "!");
            }

            string proTips = ProTips.getProandBasicTips(); //gets tips from ProTips class (derived from BasicTips)

            Console.WriteLine("Here are some final tips:");
            Console.WriteLine(proTips); //display tips
            Console.WriteLine("");
            Console.WriteLine("Thanks for Playing. Good-bye!");
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        static public void fullSeries()

        {
            // the next three lines can all be changed in the GameSettings class
            int    winsNeededToWinSeries = GameSettings.winsNeededToWinSeries;
            string userPlayerName        = GameSettings.userPlayerName;
            string computerPlayerName    = GameSettings.ComputerPlayerName;

            int userGamesWon     = 0;
            int computerGamesWon = 0;

            Console.WriteLine("Let's start the series. Good Luck!");
            while (userGamesWon < winsNeededToWinSeries && computerGamesWon < winsNeededToWinSeries) //stay in loop til someone wins 4 games
            {
                string winner = SingleGame.oneGame(userGamesWon, computerGamesWon);                  //call for a game to be played and have the winner returned

                if (winner == "user")                                                                // add a "game won" to the winner's total
                {
                    RecordBook.UpdateRecordBook("won_game");                                         //update the record books
                    userGamesWon++;
                }

                else
                {
                    RecordBook.UpdateRecordBook("lost_game"); //update the record books
                    computerGamesWon++;
                }
            }

            if (userGamesWon > computerGamesWon)           //names winner when someone gets to number needed to win series
            {
                RecordBook.UpdateRecordBook("won_series"); //update the record books
                Console.WriteLine("{0} wins the series!", userPlayerName);
            }
            else
            {
                RecordBook.UpdateRecordBook("lost_series"); //update the record books
                Console.WriteLine("{0} wins the series!", computerPlayerName);
            }
            Console.WriteLine("");
            Console.WriteLine("Press the 'P' key + <enter> to play again or the 'Q' key + <enter> to get final stats and quit");

            string playChoice = "";

            while (true)
            {
                playChoice = Console.ReadLine().Trim();                          //takes user's input
                string isInputValid = Validation.validate(playChoice, "p", "q"); // calls validation class, sends users choice and possible valid choices

                //if Validation.validate returns a NULL string there is no error.  If it returns a customer error message the error is written and loop continues

                if (isInputValid is null)
                {
                    break;
                }
                else
                {
                    Console.WriteLine(isInputValid);
                }
            }


            if (playChoice == "P" || playChoice == "p")
            {
                FullSeries.fullSeries();
            }

            else

            {
                GoodBye.goodbye();
            }
        }