Note: This exercise is based on a practice programming problem used at the ACM Southeast Regional programming contest a couple of years ago.
Note: I also put a few comments concerning this assignment on the Class Bulletin Board.
Bingo is a popular game played on a 5 by 5 grid, called a card. Normally we associate each column of the card with the letters B-I-N-G-O from left to right. Each square on the grid has a number in it. As numbers are selected, they are marked off the card. When a line of five squares, horizontal, vertical or diagonal, is marked out, the card is a winner. When a player gets a winning card, he or she shouts BINGO!
A sample bingo card is shown below:
B |
I |
N |
G |
O |
12 |
28 |
31 |
49 |
66 |
3 |
26 |
45 |
53 |
75 |
10 |
17 |
33 |
59 |
67 |
7 |
19 |
42 |
55 |
74 |
2 |
23 |
37 |
46 |
70 |
If the numbers 3, 45, 53, 75, and 26 are picked, then there will be a horizontal bingo on the second row.
The five entries in a column are random integers in the range selected from the ranges indicated below:
The goal of this assignment is to design and implement a Java program to play a game of bingo.
BingoCard
ADT (e.g., Java
class) to represent a bingo card. The class should include
appropriate internal state and operations to manipulate that state
during a bingo game. By default, a BingoCard
should be
initialized to a valid set of random values. (You may provide the
ability to initialize the card to specific values if you wish.)
You will, of course, need operations to mark the card appropriately when numbers are called, determine whether the card is a winner, to "print" the card (e.g., return the card as a string so that it can be printed), and so forth.
GameCards
ADT (class) to
represent a collection of bingo cards being played at the same time.
This class should create the number of desired cards and then accept a
sequence of random values in the range 1 to 75 that are played on the
cards. It should detect a winner and make that information available
through an appropriate feature of its interface. It should also be
possible to print the winning card(s) and/or the entire collection.
UP to CSci 691 Assignments page?