Created
April 25, 2013 00:46
-
-
Save anonymous/5456730 to your computer and use it in GitHub Desktop.
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
package Roulette; | |
import java.util.Random; | |
import java.util.Vector; | |
public class Wheel { | |
Vector bins; | |
Random rng; | |
Wheel(Random rng){ | |
rng = new Random(); | |
bins = new Vector(38); | |
for (int i=0; i<38; i++){ | |
bins.add(i, new Bin()); | |
} | |
} | |
void addOutcome(int bin, Outcome outcome){ | |
this.bins.elementAt(bin).add(outcome); | |
} | |
Bin next(){ | |
int rand = rng.nextInt(38); | |
return (Bin) bins.elementAt(rand); | |
} | |
Bin get(int bin){ | |
return (Bin) bins.elementAt(bin); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment