User Tools

Site Tools


bingo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
bingo [2021/05/02 10:51] frchrisbingo [2021/05/06 16:49] frchris
Line 5: Line 5:
 It's not just a song from summer camp, its an old-timey game: Here is a [[https://www.youtube.com/watch?v=nGCEpUAnkSg|Video Explaining the rules]]. We will start with the machine that randomly chooses the Bingo Ball to be called.  Next we will generate the player's BingoCard which the user needs to mark until a winning Bingo pattern is made.  Finally we will make a ''BingoGame'' class that will put all these elements together by showing the called numbers, the player's BingoCards and a BINGO button if the player thinks they have a winning Bingo Pattern. It's not just a song from summer camp, its an old-timey game: Here is a [[https://www.youtube.com/watch?v=nGCEpUAnkSg|Video Explaining the rules]]. We will start with the machine that randomly chooses the Bingo Ball to be called.  Next we will generate the player's BingoCard which the user needs to mark until a winning Bingo pattern is made.  Finally we will make a ''BingoGame'' class that will put all these elements together by showing the called numbers, the player's BingoCards and a BINGO button if the player thinks they have a winning Bingo Pattern.
  
-=== BingoBallHopper ===+=== 1. BingoBallHopper ===
  
  
-First we will make a ''BingoBallHopper'' class that will make all 75 bingo balls, and randomly selecting them one at a time, kepping track of which ones were called.  To save time here is the {{ ::bingoball.java |BingoBall.java}} class, the {{ ::bingohoppertester.java |BingoHopperTester}}, and the starter code {{ ::bingohopper.java |BingoHopper.java}}.  You just have to finish the constructor, the ''nextBall()'' method and ''called() method'' Read the comments above each for the details.+First we will make a ''BingoBallHopper'' class that will make all 75 bingo balls, and randomly selecting them one at a time, keeping track of which ones were called.  To save time here is the {{ ::bingoball.java |BingoBall.java}} class, the {{ ::bingohoppertester.java |BingoHopperTester}}, and the starter code {{ ::bingohopper.java |BingoHopper.java}}.  You just have to finish the constructor, the ''nextBall()'' method and ''called() method'' Read the comments above each for the details.
  
-{{::hoppertesterpic.png?400|}}+{{::hoppertesterpic.png?600|}}
  
-=== BingoCard/BingoCell ===+=== 2. BingoCell ===
  
-Next we turn to the player's Bingo cards.  We will make a clickable box for each square that we'll call the ''BingoCell'' class, then make a 5x5 grid of these which we will call the ''BingoCard'' class. +Next we turn to the player's Bingo cards.  We will make a clickable box for each square that we'll call the ''BingoCell'' class, then make a 5x5 grid of these which we will call the ''BingoBoard'' class. 
  
 The ''BingoCell'' class would be a subclass of {{ ::cell.java |Cell}}  that would add the attributes of a number and a font. It will have its own draw method that can draw its number.  Here is a hint on how to do one of the Constructors: The ''BingoCell'' class would be a subclass of {{ ::cell.java |Cell}}  that would add the attributes of a number and a font. It will have its own draw method that can draw its number.  Here is a hint on how to do one of the Constructors:
Line 27: Line 27:
   - The Cell class 3 Constructors to allow a client class more access and flexibility.  Add at least one more constructor to the ''BingCell'' class that uses one of the other ''Cell'' class's constructors. Remember to have a parameter to initialize the BingoCell's number   - The Cell class 3 Constructors to allow a client class more access and flexibility.  Add at least one more constructor to the ''BingCell'' class that uses one of the other ''Cell'' class's constructors. Remember to have a parameter to initialize the BingoCell's number
   - accessor methods so a client class can know a cell's number (getNumber, getFont, setNumber, setFont)   - accessor methods so a client class can know a cell's number (getNumber, getFont, setNumber, setFont)
-  - Change the ''draw'' method so that if the number is 0, it will draw "free" instead.+  - Change the ''draw'' method so that if the number is 0, it will draw "free" instead. Here is a hint: 
 + 
 +{{::screen_shot_2021-05-02_at_7.53.48_am.png?600|}}
    
 You can test out your BingoCell class by adapting {{ ::celltester.java |CellTester.java}} to construct new ''BingoCell''s in the ''resetCells()'' method.   You can test out your BingoCell class by adapting {{ ::celltester.java |CellTester.java}} to construct new ''BingoCell''s in the ''resetCells()'' method.  
Line 33: Line 35:
 {{::screen_shot_2021-05-02_at_7.26.45_am.png?600|hint}} {{::screen_shot_2021-05-02_at_7.26.45_am.png?600|hint}}
  
-The rest would not need to be changed since a ''BingoCell'' is a ''Cell'' Eventually, your ''BingoBoard'' class would be the ultimate test of your ''BingoCell'' class!+The rest would not need to be changed since a ''BingoCell'' is a ''Cell''.  (Eventually, your ''BingoBoard'' class would be the ultimate test of your ''BingoCell'' class)  When you are done, the ''CellTester'' application should look like something like this:
  
 +{{::screen_shot_2021-05-02_at_7.55.50_am.png?600|}}
  
 +=== 3. BingoBoard ===
  
-The ''BingoCard'' class will need: +The ''BingoBoard'' class will need: 
-  - a 2-D array of BingoCells +  - the line ''import java.awt.*;'' 
-  - a method that constructs the card so that:+  - a 2-D array of BingoCells called ''board'' 
 +  - a ''top'', ''left'' for the top corner of the board should be drawn 
 +  - a ''size'' for the of the BingoBoard.  The board will be square, because of margins, the size of the BingoCells would be a fraction of the size. 
 +  - a method ''contains(int number)'' that returns true if the number is in board, and false otherwise. 
 +  - a method ''randomInt(int min, int max)'' that returns a random number from min to max, inclusive that is not already on the board (Hint: The number of possible choices would be ''Math.abs(max-min)+1''). 
 +  - 2 Constructors: one that has three parameters (top, left, and size) and another without parameters (that sets the top and left to 0, and the size fo 350). Each  constructor so that the card so that:
       - The "B" column has 5 unique numbers from 1-15       - The "B" column has 5 unique numbers from 1-15
       - The "I" column has 5 unique numbers from 16-30       - The "I" column has 5 unique numbers from 16-30
Line 45: Line 54:
       - The "G" column has 5 unique numbers from 46-60       - The "G" column has 5 unique numbers from 46-60
       - The "O" column has 5 unique numbers from 61-75       - The "O" column has 5 unique numbers from 61-75
-  - a toString method that has no parameters, and returns a string representation of the board that is similar to : {{::bingotext.png?200|}} +  - a toString method that has no parameters, and returns a string representation of the board.  Use ''\n'' to make a newline in the String to get different rows. It should be similar to : {{::bingotext.png?200|}} 
-  - a method 'hasBingo' (that returns a boolean) which detects a win for the rows, columns, and diagonals (later you can overload this with method that takes a parameter for the "blackout," "corners," or "box" variants) +  - a method 'hasBingoSelected' (that returns a boolean) which detects a win for the rows, columns, and diagonals Sometimes there are variants of the game such as "blackout," or "corners," or "box" variants).{{::screen_shot_2021-05-02_at_10.29.23_am.png?600|}}    
-  - a draw method takes a Graphics parameter to draw the board+  - a draw method (that takes a Graphics parameter) which calls all the ''BingoCell''s in ''board'' to draw themselves. 
 + 
 +The "Extreme Programming" approach is to begin by writing one or more  client classes of ''BingoBoard'' to test each of these specifications. The first 4 can be done with a text based application, starting off with a simple one like 
  
-The "Extreme Programming" approach is to begin by writing one or more  client classes of ''BingoBoard'' to test each of these specifications. The first 4 can be done with a text based application, starting off with a simple one like {{::simpletester.png?200|}}+{{::simpletester.png?600|}}
  
-The draw method can be tested by a ''BingBoardTester'' that you could start by adapting the ''CellTester'' code.+The draw method can be tested by {{ ::bingoboardtester.java |BingoBoardTester}}  that might look like this: 
 +{{::screen_shot_2021-05-06_at_11.29.45_am.png?600|}}
  
-=== BingoGame ===+=== 4. BingoGame ===
  
 The ''BingoGame'' class can have one or more BingoBoards and random numbers from 1-75 can be "called out." These are randomly selected, but each number can only be called out once.  The number called is only on the screen temporarily (you probably want to use the javax.swing.Timer like the [[https://mathorama.com/apcs/pmwiki.php?n=Main.SimonGame|Simon Game]] The ''BingoGame'' class can have one or more BingoBoards and random numbers from 1-75 can be "called out." These are randomly selected, but each number can only be called out once.  The number called is only on the screen temporarily (you probably want to use the javax.swing.Timer like the [[https://mathorama.com/apcs/pmwiki.php?n=Main.SimonGame|Simon Game]]
bingo.txt · Last modified: 2021/05/10 12:08 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki