import java.util.Random;
public class CompetitionWinners {
private static String[] contestants = { "leandro", "Freaky Chris",
"pmural", "Pooja Deshpande", "chals", "mBrian", "kairamr",
"loonatic", "btedford", "blackJava", "Jchang504", "xuming9",
"clow2821", "mpoland", "bebooahlawy", "fourseven", "yogita281",
"jega004", "Splat", "slaw77pl", "aks_java", "sriram", "Fendaril",
"Dalisra", "dewboy3d", "luke", "Flash", "marksquall" };
private static String firstPlace, secondPlace, thirdPlace;
private static int randomInt;
static Random random = new Random();
public void First() {
// GENERATE FIRST PLACE WINNER
for (int a = 0; a < 3; a++) {
randomInt = random.nextInt(28);
}
firstPlace = contestants[randomInt];
Second();
}
public void Second() {
// GENERATE SECOND PLACE WINNER
for (int a = 0; a < 3; a++) {
randomInt = random.nextInt(28);
}
secondPlace = contestants[randomInt];
if (secondPlace.equals(firstPlace)) {
Second();
}else{
Third();
}
}
public void Third() {
// GENERATE THIRD PLACE WINNER
for (int a = 0; a < 3; a++) {
randomInt = random.nextInt(28);
}
thirdPlace = contestants[randomInt];
if (thirdPlace.equals(secondPlace) | thirdPlace.equals(firstPlace)) {
Third();
}else{
}
}
public void GenerateWinners() {
First();
}
public static void main(String[] args) {
CompetitionWinners cw = new CompetitionWinners();
cw.GenerateWinners();
System.out.println("1st Place : " + firstPlace);
System.out.println("2nd Place : " + secondPlace);
System.out.println("3rd Place : " + thirdPlace);
System.out.println();
System.out.println("All winners selected");
}
}