Skip to content

Instantly share code, notes, and snippets.

@donyd
Created January 17, 2021 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donyd/1275c2ea2ef364325b3344261775d8c9 to your computer and use it in GitHub Desktop.
Save donyd/1275c2ea2ef364325b3344261775d8c9 to your computer and use it in GitHub Desktop.
using System;
namespace WhoGoesNext
{
class Program
{
static void Main(string[] args)
{
// starting variables
int randomNumberGiven = 46;
int currentPlayer = 0;
int numberOfPlayers = 4;
int nextRandomNumber = 0;
// get next player based on random received
currentPlayer = randomNumberGiven % numberOfPlayers;
// get next random number
nextRandomNumber = getNextRandom();
Console.WriteLine("Player {0}'s turn", currentPlayer);
Console.WriteLine("Next random number is: {0}", nextRandomNumber);
Console.ReadLine();
}
private static int getNextRandom()
{
// create random seed
Random rand = new Random();
// return random number with limit 99
return rand.Next(99);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment