public class BingoMac { public static int drawNum(){ Random rand = new Random();
ID: 3540903 • Letter: P
Question
public class BingoMac {
public static int drawNum(){
Random rand = new Random();
int num = rand.nextInt(75)+1;
return num;
}
public static void bingoCard(){
int [][]card=new int [5][5];
ArrayList<Integer> alreadyUsed = new ArrayList<Integer>();
boolean valid = false;
int tmp = 0;
for(int i = 0; i <= 4; i++){
for(int row = 0; row < card.length; row++){
while(!valid){
tmp = (int)(Math.random() * 15) + 1 + 15 * i;
if(!alreadyUsed.contains(tmp)){
valid = true;
alreadyUsed.add(tmp);
}
}
card[row][i] = tmp;
valid = false;
}
}
card[2][2] = 0;
//create array to make title.
String title []={"B","I","N","G","O"};
for(int i=0;i<title.length;i++){
System.out.print(title[i]+ " ");
}
System.out.println();
for(int row=0;row<card.length;row++){
for(int col=0;col<card[row].length;col++){
System.out.print(card[row][col]+ " ");
}
System.out.println();
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
bingoCard();
}
}
I have two methods here - one that populates the output with a Bingo Board, and a random number generator that pulls numbers from 1 - 75.
I want the Bingo Board Game to play itself, meaning, using the drawNum method, correspond whether or not this integer matches any integer within my bingoCard array. Can you complete this for me? The winning conditions are vertical, horizontal, and diagonal integers all set to "marked."
Explanation / Answer
please see here http://pastebin.com/C3iVM949
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.