/** * Starter code for the BingoBoard class * * @author * @version */ import java.awt.Color; import java.awt.Graphics; public class BingoBoard { // your code here public BingoBoard() { this(0, 0, 350); } public BingoBoard(int tp, int lft, int size) { this.top = tp; this.left = lft; this.size = size; board = new BingoCell[5][5]; int cellSize = this.size/7; int gap = 3; for(int c = 0;c < 5; c++) for (int r=0; r< 5; r++) { board[r][c] = new BingoCell(left + (c+1)*(cellSize + gap), top +(r+1)*(cellSize + gap), cellSize, Color.WHITE, randomInt(1+c*15,15+c*15)); } board[2][2].setNumber(0); } public BingoBoard() { // your code here } public int randomInt(int min, int max) { int n = Math.abs(max-min+1); int result = min + (int)(n*Math.random()); while (this.contains(result)) { result = min + (int)(n*Math.random()); } return result; } public boolean contains(int number) { // your code here } public String toString() { String result = " B | I | N | G | O \n----------------------\n"; // your code here } return result; } public boolean hasBingoSelected() { // check for the diagonals if (board[0][0].isOn() && board[1][1].isOn() && board[3][3].isOn() && board[4][4].isOn() ) return true; if (board[4][0].isOn() && board[3][1].isOn() && board[1][3].isOn() && board[0][4].isOn() ) return true; // check for rows and columns // your code here return false; } public boolean hasBlackoutSelected() { int total = 0; for(BingoCell[] row:board) for(BingoCell cell:row) if (cell.isOn() ) total++; return total == 25; } public boolean hasCornersSelected() { return board[0][0].isOn() && board[0][1].isOn() && board[1][0].isOn() && board[1][1].isOn(); } public static void main(String[] args) { for(int i=0; i<3; i++) { BingoBoard b = new BingoBoard(); System.out.println(b); } } public void draw(Graphics g) { // your code here (tell each BingoCell to draw itself) } public boolean cellClick(int x, int y) { for( BingoCell[] row:board) for (BingoCell c:row) if (c.contains(x, y)) { c.click(); return true; } return false; } public void cellHover(int x, int y) { for( BingoCell[] row:board) for (BingoCell c:row) c.setHighlight(c.contains(x, y)); } }