Bingo Game Lab

Kelly Schultz and Alyce Brady
Kalamazoo College

 


For week two, you wrote a program that put the letters on a grid so that it resembled a Bingo Card. In this lab and follow-up programming project you will implement a working Bingo Game from an existing skeleton.

What is the game of Bingo?
The rules of Bingo are quite simple. A Bingo game consists of a series of rounds. Within each round, a caller repeatedly pulls numbers, in the range from 1 to 75, from a contraption similar to lottery ball holders. He or she puts the number up on a screen, then calls out the number. Players have a certain number of seconds to find the number on their Bingo cards. Each card has a random selection of numbers. The "B column contains random numbers between 1 - 15, the "I" column has numbers between 16 - 30, the "N" column has numbers between 31 - 45 (with a free space in the center), the "G" column has numbers between 46 - 59, and the "O" column has numbers between 60 - 75. When a player finds a matching number on their card, they mark it as found (for example, with a marker or pen). Whoever is the first to fill a complete line of numbers on their card, whether horizontally, vertically, or diagonally, yells "BINGO!" loudly and wins the round. Then everyone clears their cards (or takes new cards), and a new round starts.
image showing "B" "I" "N" "G" "O" column headings

The skeleton program provided for this lab creates a graphical user interface for a Bingo Card (without the "BINGO" column headings), fills the card with some numbers, and then chooses 5 random numbers and looks for them on the card. It "marks" each number it finds on the card by changing its color.

The program needs several enhancements to act like a real Bingo game. One problem is that the card should be initialized with a different set of random numbers every time the game is played; instead, this version places the same pre-defined numbers in each column every time. This is one of the improvements you will make in the follow-up programming project. The focus of the lab will be on a more important problem: the "game" currently consists of calling out only 5 random numbers, whereas it should continue to call out random numbers until there is a winning Bingo pattern on the card. (A real game with multiple cards would continue until one of the cards has a winning pattern, but our game has only one card.) There are a variety of patterns that could be considered a winning pattern in Bingo, such as a complete row of marked numbers, a complete column of marked numbers, marked numbers in the four corners, etc. Each of these could be considered a separate strategy for winning.

Lab: Defining and Implementing Interfaces, Using the Strategy Design Pattern

In this lab you will create an interface for classes that implement different winning strategies, and then create two strategy classes. In the follow-up programming project you will implement additional winning strategies and make several other improvements to the program.

Become familiar with the program.

Create a WinningStrategy interface.

Implement a WinningStrategy class.

Implement a second WinningStrategy class.

Support wins based on multiple strategies.

Submit your modifications.