User Tools

Site Tools


bingo

This is an old revision of the document!


Bingo

It's not just a song from summer camp, its an old-timey game: Here is a Video Explaining the rules

First we will make a BingoBallHopper class that will make all 75 bingo balls. To save time here is the BingoBall.java class.

Next BingoCell class, then a BingoCard class, and finally we will make a BingoGame class.

The BingoCell class would be a subclass of 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 build upon the draw method of the parent class: For now, let a cell that is “off” represent an uncalled number, and a “on” cell be one that the player has clicked on when that number is called. Later you may wish represent a called number differently. The class should have the following:

  1. Constructors that can will allow a client class to initialize the digit (the number 0 can be used as the center “free” cell
  2. accessor methods so a client class can know a cell's number

You can test out your BingoCell class by adapting CellTester.java to construct new BingoCells in the resetCells() method. 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 BingoCard class will need:

  1. a 2-D array of BingoCells
  2. a method that constructs the card so that:
    1. The “B” column has 5 unique numbers from 1-15
    2. The “I” column has 5 unique numbers from 16-30
    3. The “N” column has 4 unique numbers from 31-45, with the center a “Free” cell
    4. The “G” column has 5 unique numbers from 46-60
    5. The “O” column has 5 unique numbers from 61-75
  3. a toString method that has no parameters, and returns a string representation of the board that is similar to :
  4. 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)
  5. a draw method takes a Graphics parameter to draw the board

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 draw method can be tested by a BingBoardTester that you could start by adapting the CellTester code.

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 Simon Game

It is up to the player to “dob” or select the ones that are called. There should be a bingo button for the player to press if they think they have a “Bingo”.

bingo.1619900630.txt.gz · Last modified: 2021/05/01 16:23 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki