Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

import java.util.*; public class Bingo_Card { int[][]card = new int [5][5]; publ

ID: 3541045 • Letter: I

Question

import java.util.*;

public class Bingo_Card

{

    int[][]card = new int [5][5];

public Bingo_Card()

{

    ArrayList<Integer> alreadyUsed = new ArrayList<Integer>();

    boolean valid = false;

    int tmp = 0;

    for(int col = 0; col <= 4; col++)

    {

        for(int row = 0; row < card.length; row++)

        {

            while(!valid)

            {

                tmp = (int)(Math.random() * 15)+1 + 15 * col;

                if(!alreadyUsed.contains(tmp))

                {

                    valid = true;

                    alreadyUsed.add(tmp);

                }

            }

            card[row][col] = tmp;

            valid = false;

        }

    }

    card[2][2] = 0;

}

public void print_card()

{

    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++)

    {

        System.out.print("|");

        for(int col = 0; col < card[row].length; col++)

        {

            System.out.print(card[row][col] + " |");

        }

        System.out.println(" _________________________________________");

    }

}

public void check_match(int input)

{

    for(int col = 0; col <= 4; col++)

    {

        for(int row = 0; row < card.length; row++)

        {

            if(card[row][col]==input)

            {

                card[row][col] = 0;

            }

            else

            {

                continue;

            }

        }

    }

}

public boolean check_bingo()

{

if(card[0][0]==0&&card[0][1]==0&&card[0][2]==0&&card[0][3]==0&&card[0][4]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[1][0]==0&&card[1][1]==0&&card[1][2]==0&&card[1][3]==0&&card[1][4]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[2][0]==0&&card[2][1]==0&&card[2][2]==0&&card[2][3]==0&&card[2][4]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[3][0]==0&&card[3][1]==0&&card[3][2]==0&&card[3][3]==0&&card[3][4]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[4][0]==0&&card[4][1]==0&&card[4][2]==0&&card[4][3]==0&&card[4][4]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[0][0]==0&&card[1][0]==0&&card[2][0]==0&&card[3][0]==0&&card[4][0]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[0][1]==0&&card[1][1]==0&&card[2][1]==0&&card[3][1]==0&&card[4][1]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[0][2]==0&&card[1][2]==0&&card[2][2]==0&&card[3][2]==0&&card[4][2]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[0][3]==0&&card[1][3]==0&&card[2][3]==0&&card[3][3]==0&&card[4][3]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[0][4]==0&&card[1][4]==0&&card[2][4]==0&&card[3][4]==0&&card[4][4]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[0][0]==0&&card[1][1]==0&&card[2][2]==0&&card[3][3]==0&&card[4][4]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else if(card[4][4]==0&&card[3][3]==0&&card[2][2]==0&&card[1][1]==0&&card[0][0]==0)

{

    System.out.println("YOU WIN THE BONGO GAME");

    System.exit(0);

    return true;

}

else

{

    return false;

}

}

public static void main(String[] args)

{

    Bingo_Card BINOFINAL = new Bingo_Card();

    BINOFINAL.print_card();

    Scanner newInput = new Scanner(System.in);

    while(!BINOFINAL.check_bingo())

    {

        System.out.print("Please play the game,Enter Bingo Number: ");

        int input = newInput.nextInt();

        BINOFINAL.check_match(input);

        BINOFINAL.print_card();

    }

}

}


In the game of bingo, a player given a card with 24 numbers (plus a free spot in the middle) oriented in a 5x5 fashion The columns have five numbers (the third column has four numbers plus the free spot). Each column can have the following possible numbers oriented In a random fashion: The take-home part of this final is to modify your two class files so that a graphical representation is supported, shown in a frame, with the general format shown in Figure 2. The card should be updated with red circles that cover the number whenever a match is made. As previously dictated, you will have to modify your two class files to support a new class called make card, which is responsible for drawing the card every time there is a need to update. Figure 1 displays a typical bingo card format. Note the order of the numbers in the bingo card vary across different bingo cards. The card should have the format in Figure 2, including: Lines that make the general card T The numbers should be printed on the card in bold, 24-point times font Either red or yellow circles that cover the proper number each time a number matches one of the called numbers. The letters BINGO should be blue, and bold, 44 point Arial font. Each letter should be posted above their respective column The frame title should have the words "BINGO Card" successful integration of the graphics with the original in-class program In this project, the way to win the bingo game Is If there are spots filled in a straight line, whether it is column wise, row-wise, or along the diagonals. The project must have two classes, one for the mam program, and the other that deals with making and operating on the bingo card. The class that pertains with the bingo card itself should be called Bingo_Card, and should consist of the following: A constructor called Bingo_Card that creates and initializes the bingo card (20 points) A method called print_card that prints out the card (same design as in Figure 1) A method called check_match that checks to see if the number chosen matches a value on the card. If there's a match, place a zero on the value of the location. A method called check_bingo that checks to see if a bingo exists The mam program should be called BINOFINAL, and should be able to take input from the user via the keyboard until a bingo happens. Note, in this game, we will only use integer numbers instead of the alphanumeric combination (e.g., we will use 13 instead of B13). After each value is entered, it should print the current version of the card, with some indication for covered numbers.

Explanation / Answer

import java.util.*;

  

/**

* @version Bingo Card Generator v1.0

* @author Troy Martin

*/

public class BingoBoard {

  

public static void drawBoard() {

System.out.println();

System.out.println(" B I N G O");

  

for(int j = 0; j<BOARD_SIZE; j++) {

System.out.print(" |");

for(int i = 0; i<BOARD_SIZE; i++) {

if(board[i][j] < 10)

System.out.print(board[i][j] + " |");

else

System.out.print(board[i][j] + "|");

}

System.out.println(); // new line

}

}

  

public static void main(String[] args) {

// initialize random generator from a collection of numbers 1-15

Random generator = new Random();   

List<Integer> generated = new ArrayList();

  

// roll for random values in bingo board

for(int i = 0; i<BOARD_SIZE; i++) {

while(true)

{

int roll = generator.nextInt(15) + 1; // 1-15

if (!generated.contains(roll))

{

generated.add(roll);

board[0][i] = roll;

break;

}

}

}

for(int i = 0; i<BOARD_SIZE; i++) {

while(true)

{

int roll = generator.nextInt(15) + 16; // 16-30

if (!generated.contains(roll))

{

generated.add(roll);

board[1][i] = roll;

break;

}

}

}

for(int i = 0; i<BOARD_SIZE; i++) {

while(true)

{

int roll = generator.nextInt(15) + 31; // 31-45

if (!generated.contains(roll))

{

generated.add(roll);

board[2][i] = roll;

break;

}

}

}

for(int i = 0; i<BOARD_SIZE; i++) {

while(true)

{

int roll = generator.nextInt(15) + 46; // 46-60

if (!generated.contains(roll))

{

generated.add(roll);

board[3][i] = roll;

break;

}

}

}

for(int i = 0; i<BOARD_SIZE; i++) {

while(true)

{

int roll = generator.nextInt(15) + 61; // 61-75

if (!generated.contains(roll))

{

generated.add(roll);

board[4][i] = roll;

break;

}

}

}

  

drawBoard();

System.out.println();

}

static int BOARD_SIZE = 5;

static int[][] board = new int[BOARD_SIZE][BOARD_SIZE];   

}