Question: We want to write a Java program to simulate a simplified version of bingo game. Players use cards that feature five columns of five cells

We want to write a Java program to simulate a simplified version of bingo game. Players use cards that feature five columns of five cells each (a 5x5 matrix), with every cell containing a number between 1 to 90. In each step of the game a number between 1 and 90 is called randomly and players need to mark the number in their card if they have it. The first player who marks all of the numbers in one row of one of his/her cards is the winner of the game. Following is the skeleton of the classes that you need to complete:

//class Bingo should have an array of Player objects as its instance field. 

class Bingo {

public Bingo(Player[] players);

Creates an object of Bingo game using an array of Player objects passed as an argument.

public String play(int number);This is the main method for playing the game. It takes a number (the number that is called) and marks the cells with that number in all players cards. It also returns the name of the winner, if any. If there is no winner, it return an empty string. If there is more than one winner, it returns the name of all winners as one string, separated by space (again, no space at the end of the String). For example, if player1, player2, and player3 win the game in one turn, it returns "player1 player2 player3". 
} //class Player should include an array of Card objects as well as the name of the Player object as a String.class Player {public Player(String name, Card[] cards);

Creates a Player object using the name of the player and an array of bingo cards for the player.

public String getName();Returns the name of the player. 
public Card[] getCards();

Returns player's bingo cards.

public boolean isWinner();

Checks if the player is a winner.

public void markNumber(int number);

Takes a number and marks that number in all bingo cards of the player.

} //class Card should include a 2D array of integers (5x5) for numbers shown on the Card object. For each one of those numbers, it should also track if the number is marked or not.class Card {public Card(int[][] numbers); 

Uses an array of 5x5 and fills the bingo card by those numbers.

public int getNumber(int Row, int Column); 
Returns the number in the cell at row and column of the bingo card.

public boolean isMarked(int row, int column);
If the cell at row and column of the card is marked, returns true, otherwise, returns false.

public void markNumber(int number);
Takes a number and if the number exists in the card, marks that cell of the card.

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!