Permalink
Cannot retrieve contributors at this time
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?
Roulette_Game/Wheel.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33 lines (29 sloc)
1015 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} | |
} |