Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
public class Wheel
{
// Array of numbers on the roulette wheel
public int[] numbers;
// Array of colors on the roulette wheel
public string[] colors;
// Constructor to initialize the wheel with numbers and colors
public Wheel()
{
numbers = new int[] { 0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26 };
colors = new string[] { "Green", "Red", "Black" };
}
// Simulates spinning the roulette wheel and returns the winning number
public int SpinWheel()
{
Random random = new Random();
return numbers[random.Next(0, numbers.Length)];
}
// Returns the color corresponding to the given number
public string GetColor(int number)
{
if (number == 0)
return colors[0];
else if (number % 2 == 0)
return colors[1];
else
return colors[2];
}
}