AS 2019 RandomPlayerStarts

From TRCCompSci - AQA Computer Science
Revision as of 08:08, 1 April 2019 by Admin (talk | contribs) (Where)
Jump to: navigation, search

Where

Find the Game method, and look for:

string nextPlayer = "a";

Idea

create a random, then generate a random number, and then use it to decide if A or B goes first.

so:

string nextPlayer;
if (rnd.Next(100) <= 50)
   nextPlayer = "a";
else
   nextPlayer = "b";
Console.WriteLine(nextPlayer + " goes first!!");