Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I could use some help with the following Java Bingo project. Project 2 - BINGO CS 0401Intermediate Programming using Java Check the Due Date

Hi, I could use some help with the following Java Bingo project.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Project 2 - BINGO CS 0401Intermediate Programming using Java Check the Due Date on the CourseWeb ngo (Modified from Wikipedia) In the United State, Bingo is a game of chance in which each player matches numbers printed in different arrangements on 5 x 5 cards which the numbers the game host (caller) draws at random, marking the selected numbers with tiles. When a player finds the selected numbers are arranged on their card in a row, they call out "Bingo!" to ale all participants to a winning card, which prompts the game host (or an associatc assisting the host) to cxaminc the card for verification of the win. Players compete against one another to be the first to have a winning arrangement for the price or jackpot. After a winner is declared, the players clear their number cards of the tiles and the game host begins a new round of play Bingo Cards The most common Bingo cards are flat piece of cardboard or disposable paper whi squares arranged in five vertical column and five side to side rows. Each space in the grid contains a number ch contain 25 A typical Bingo game utilizes the numbers 1 through 75. The five columns of the card are labeled B, I, N, G and O from left to right. The center space is usually marked "Free" or "Frec Space". and is considered automatically filled. The range of printedbers that can appear on the card is normally rcstricted by column, with the B column only containing numbcrs bctwccn 1 and 15 inclusive, the I column containing only 16 through 30, N containing 31 through 45, OG containing 46 through 60, and O containing 61 through 75. Here is an example of a Bingo card 15 2742 557 10294156 73 7 26 14752 64 1321 365961 8 23325874 SPACE The Goal The goal of this project is for you to create a host program that manages the Bingo game. Each round o ane, there can be a number o players n round o game, a plaver can have any number of Bingo cards. To make it interesting, each card wl costs $1. Half of the cost of a card will go to the host, the other half w be placed into a pot. When the game begins, the host will draw a Bingo ball (a ball with a number between 1 and 75) at random from a Bingo Cage. Balls will be drawn one at a time until a player gets the BINGO. Whoever wins that round will get all the money in the pot As usua, you are going to implement your program according to the Object-Oriented Program- ming (OOP). Read descriptions in the next sections carefully. You may think that there are way to many classcs and somc of thcm arc not ncccssary. Just stick with the dcscription. Wc want you to practice dealing with multiple classes and objects. Each class will have its own set methods. How- ever, if you need to create additional mcthods, thosc methods must bc declared private. Again all classes suggested in the next sections must be implemented with methods described in the next sections. Part I: The BingoNumber Class (5 Points) A Bingo number is a number displayed on a Bingo card. A Bingo number can be marked by a player. Whether a number is marked, a player will always see the number of the card. So, from the above observations, the BingoNumber class should have the following Constructors -public BingoNumber(int aNumber): This constructor constructs an object of type BingoNumber with the given number (aNumber) Accessor ethods public int getNumber() returns the integer representing the number of the BingNumber Note that even if the number is marked, it s returns ts number as usual public boolean isMarkedO returns true or false whether the number is marked -public String toString() returns a two-digit string presentation of a BingoNumber The output string depends on whether the number if marked. If the number is not marked yet, simply show the number. However, if the number is marked, the output string will simply be XX. Here is an example of a code snippet and expected output where the mark ) and toNumberString) mcthods will be discussed next: BingoNumber n1 new BingoNumber(5); BingoNumber n2- nez BingoNumber (12); n2.mark) System.out.println(n1); System.out.println(n1.toNumberString()); System.out.println(n2); System.out.println (n2.toNumberString)); Output 5 12 public String toNumberString) returns a two-digit string representation of a BingoNumber as i it has not been marked yet Mutator Method public void mark) marks the BingoNumber. Note that once the number is marked. It cannot be unmarked because we are not going to supply a method that will let users unmark a Bingo nmber Instance Variables: It is your turn to figure it out what would be the set of instance variables of this class Part II: The BingoCard Class (15 Points) Here is an example of a Bingo card (on a console screen): I 5119140155162l 1141161451591611 | 61271XX1521661 121291371581701 I 4128142153163 As you may notice above, a BingoCard looks like a two-dimensional array of size 5x5 of BingoNumber objects. According to the Bingo card discussed previously, the numbers in cach row are randomly generated. Each row has its own range of numbers (see description above). A user can mark numbers on the card. With these requirements, here are implementation details . Constructors - public BingoCardO: constructs a BingoCard objcct whcrc all 21 numbcrs arc objccts of type BingoNumber constructed using randomly generated numbers. Do not forget that there is no BingoNumber in the middle of a Bingo card . Accessor Methods -public String toString(): returns a string representation of a Bingo card. An ex ample is the one shown above which is the output of the following code snippet B I N G O | 51 19140155162 5119140155162l 1141 16 | XXI59161 141 161451591611 | 6127IXXI52166 61271XXI521661 112129137 58170 121291371581701 | 4128142153163 4128142153163 B I N G For the side-by-side string, the card on the left is the one that is marked, and the one on the right shown the unmarked version of the card for the host to verify. Instance Variables: Again, think about this yourselves what are the set of instance variables and their types should be Part III: The BingoBall and BingoCage Classes (5 and 10 Points) A Bingo ball is simply a ball with a number. A Bingo cage when constructed, it will contain 75 unique Bingo balls (ball numbers 1 through 75). A user can draw Bingo balls out of this cage one at a time. Each time a Bingo ball will be randomly picked. Note that once a ball is drawn, it cannot be redrawn again until the Bingo cage is reseted (put all Bingo balls back into the cage) For the BingoBall class, it must have at least the following constructor and methods public BingoBall(int number): This is a contstructor that constructs a Bingo ball with a given number public int getNumber ): This method returns the integer representation of a Bingo ball (e.g., the ball number) public String toStringO: returns the string representation of the number of the Bingo ball For the BingoCage class, it must have the following methods public BingoCage) This is a constructor that constructs a Bingo cage containing 75 unique Bingo balls (75 objects of type BingoBall) public BingoBall draw): This method randomly returns a Bingo ball (object of type BingoBal1). Note that if there are no more Bingo balls left, this method should return null public void reset () which resets the cage back to the original 75 unique Bingo balls, Part IV: The BingoPlayer Class (30 Points) This class represents a Bingo player which has the following abilities . A player has his/her first and last name A player will have his/her initial amount of oney when he/she walks into a Bingo house . A player will have a hand that can hold any number of Bingo card. . A player can be ordered to pay for a number of Bingo cards . A player can receive a number of Bingo cards to put into his/her hand . A player can mark nmbers on his/her Bingo cards . A player can recognize whether a card is a winning card (BINGO!) . A player can show his/her winning card(s) to the house to verify . A player can receive an amount of US Dollar if he/she wins a round. . A player can discard all Bingo cards from his/her hand This class wl be a little bit big. Here are implementation details . Constructor: -public BingoPlayer(String first, String last, double amount) constructs a Bingo player with with a given first name, last name, and the initial amount of money. Note that initially the hand of a Bingo player is empty (no Bingo cards) . Accessors: - public String getFullName ) returns the string representation of the full name ofa -public String getFull Info() returns the string representation of the full information -public String toString() returns a string representation of a Bingo player together Bingo player (first name a blank and last name) (full name and the current amount of money) of a Bingo player (see example below) with his/her Bingo cards in his/her hand The following code snippet below uses the first three accessors above where the setBingoCards () method will be discussed later: Person john -new Person ("John", "Smith", 50.0); BingoPlayer aPlayer nex BingoPlayer (john) System.out.println("getFullName ): "+aPlayer.getFullName()); System.out.println("getFullInfo O "+ aPlayer.getFullInfo)); System.out.println("-"); System.out.println(aPlayer); System-out . printin ( "===='') ; BingoCard [] cards= new BingoCard [3]; cards [0]-new BingoCardO; cards [1] new BingoCardO cards [2] = new BingoCard(); aPlayer.setBingoCards (cards); System.out.println(aPlayer); The above code snippet should give you the following output (Bingo cards will be dif ferent) getFullName (): John Smith getFullInfo) John Smith ($50.0) John Smith ($50.0) ingo Cards John Smith ($50.0) B I N G C B I N G O B I N G O 113|25137 56163 10129131152171 4119136 50174l 111221 XX149173 8123 1 XX156163 61251 XX1481681 | 8124140155175 61 17136153172 9128135157163l 15|27135 59167 2120144159 168 5127138151173 public boolean isBingo ) returns true or false whether the player has one or more winning card(s) public BingoCard[] getBingoCards returns an array of type BingoCard that are winning cards s method will be called by the host to verify whether the card(s) is the winning card(s) . Mutators: -public int remove (int amount) removes a given amount in US dollars from a Bingo playcr. Note that if the playcr has cnough fund, the rcturn valuc will be the cxact amount to remove. Otherwise, the return value will be the largest integer value that the player can play (the money that he/she has rounded down to integer). Do not forget that this method must adjust the amount of money that the player has - public void add(double amount) adds more money into the player's pocket -public void addBingoCards (BingoCard[] cards) adds Bingo cards into the player's hand in the form of an array of BingoCard. Note that the parameter is an array of type BingoCard. The size of the array must be exactly the number of Bingo cards that the player wants to buy (and have enough money) - public void marks (int number) marks all Bingo cards in the player's hand that con tain the given number 2. Ask cach Bingo player whether he/she wants to play in this round If the player says no (n) move on to the next player If the player says yes (y), ask how many Bingo cards (up to 4 cards) he/she wants to If the player says between 1 and 4, take the money from the player. Do not forget to check the amount of money in case the player does not have enough money. Then give the player the appropriate number of Bingo cards If no players wants to play in this round, just exit the program. Here is an example: David Smith, would you like to play this round? (y): y How many Bingo card would you like to buy? (1 - 4): 4 James Johnson, would you like to play this round? (y): n James Smith, would you like to play this round? (y): n Maria Garcia, would you like to play this round? (y): y How many Bingo card would you like to buy? (1 - 4) 4 Maria Hernandez, would you like to play this round? (y) n Maria Martinez, would you like to play this round? (y): n Maria Rodriguez, would you like to play this round? (y): y How many Bingo card would you like to buy? (1 4): 4 Mary Smith, would you like to play this round? (y): n Robert Smith, would you like to play this round? (y): n Michael Smith, would you like to play this round? (y): n 3. Make sure that the Bingo cage has all 75 balls (either reset the old object or construct a new one 1. Show the amount of money of the house, the amount of money in the pot, the list of ball numbers (should be epty at the beginning) and show only those players that are playing (togcther with his/hcr hand) in this round House: $62.0 Pot: $6.0 Balls: C] 1. David Smith ($42.0) B I N G C | 6127145157168 61191451471651 13123140153175 8122143 571651 | 4128137146162 101211381501671 8124135156171 61 19133151169 l | 7118| XXI55170 31241XXI571611 31 171XXI55167 21281XX148173 121 19138147172 8116136158163 1120138148161 1131271411531681 | 51 16136150173 11125135149172 5126142154163 11241401561 671 B I N G O B I N G O B I N G O Garcia (946.0)512614215435368, 11123137155168 10130135160166 114128133155164 11221411521621 7122132160166 7119137158175 10123145151168 I 31251371491741 | 1121XX151 1691 81261XX151174 41221XX 153172 8124lXXI 54166 101 16140153163 9116138153168 5127141160165 121291351591 68l 15 18133157171 6127142157164 121 16143147170 61201401511731 3. Maria Rodriguez ($46.0) B I N G B I N G O | 6120145157165 7128142160165 1126144151 166 151 161361461 62 | 5128131149 166 2126136156163 13124140157 74 1117134155168 | 11 171 XX I60173 41231XX151162 151 171XXI59167 113130IXXI601701 15 16134153 75 11129144154169 12123 43152165 12|271391521721 | 4127138150169 5118140158172 14125141156161 11120131151169l There is no winning card yet 5. There are two options from here; (1) draw one ball and check the output or (2) draw balls until a player gets a BINGO. So, ask the user: 1) Draw a ball, 2) Draw balls until Bingo: 6. Draw a Bingo ball from the Bingo cage 7. Tel each player in this round to mark the number (ball's number) 8. Check each player in this round whether he/she have a winning card If a player has a winning card, go to step 9 If no player has a winning card, go back to step 4 if the user chooses choice number 1 (Draw a ball). Go to step 4 (but skip step 5) if the user chooses choice number 2 (Draw bals Bingo) 9. Show the winning card (side-by-side) on the console screen for the house to verify. Maria Rodriguez says this card is a winning card XXIXX136146 |XXI 151 161361461621 10 Take a pick: 1) Play a Tower of Hanoi Puzzle 2) Exit Note that the program should go back to the beginning. An output of a run is also posted on the CourseWeb named output toh.txt. Submission The due date of this project is stated on the CourseWeb. Late submissions wil not be accepted For this project, you have to submit the following files: Disk.java Pole.java TowerOfHanoi.java .TowerOfHanoi Puzzle.java Zip them in to one file named project2.zip and submit the file project2.zip via CourseWeb

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions