Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the assignment needs to all fall under one main class with some additional classes that are not marked as public. We want to write a

 the assignment needs to all fall under one main class with some additional classes that are not marked as public. 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".
 

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.

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. 

}

 

Sample Input:

2 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 5 1 2 3 4 5

Sample Output:

Enter how many players there are How many cards does player 0 have? Please enter 25 numbers for card 0 of player 0 How many cards does player 1 have? Please enter 25 numbers for card 0 of player 1 Please enter how many numbers will be called Please enter 5 numbers to be called in order Player0 Player1

 
 

 
 

 
 

 

 

 

 
 
 
 
 
 
 
 
 

 
 

 
 

 

 

 

 
 
 
 
 
 
 
 
 

 
 

 
 

 

 

 

 
 
 
 
 
 
 
 
 

 
 

 
 

 

 

 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Show that the secular equation (9.82) can be written as

Answered: 1 week ago

Question

Leverage networking opportunities

Answered: 1 week ago

Question

3. How frequently do the assessments occur?

Answered: 1 week ago