dramire83 / CIS_285

CIS_285
0 stars 0 forks source link

Code - turnChosen method #25

Closed jwood36 closed 1 year ago

jwood36 commented 1 year ago

A simple question "Go first (y/n)?" should be applied. If I say Yes, then it only effects the first turn of the game; if No, again only affects the first turn of the game.

Don't make your logic overly complex long-term, always challenge yourself to minimize your approach. In other words, just because you implemented today, does not mean your married to that design tomorrow.

Also review your while loop and change it to a Do-While; since you need this to execute at least once.

For My Reference:

        private static int turnChosen()
        {
            Console.WriteLine(" Would you like to play first or second please enter 1 or 2.");
            validInfo = Console.ReadLine();
            isInRange = int.TryParse(validInfo, out playerTurn);
            while (!isInRange || playerTurn < 1 || playerTurn > 2)
            {
                Console.Clear();
                welcomeSign();
                playerTurn = 3;
                Console.WriteLine(" Invalid entry! ");
                Console.WriteLine(" Would you like to play first or second please enter 1 or 2.");
                validInfo = Console.ReadLine();
                isInRange = int.TryParse(validInfo, out playerTurn);
            }
            return playerTurn;
        }
dramire83 commented 1 year ago

Loop logic changed to Do-While to execute for better performance.