CIS 35A-- Java Programming
Upload to Canvas the source files (.java files) and screen output (copied and pasted to the
end of the file with main) (upload in one ZIP file, please)
NOTE: You need to read Lesson 5 before attempting this assignment!
You will be re-doing Prog. HW#2 in an object-oriented way, BUT IF THERE WERE
ERRORS in HW#2, it is the STUDENT'S RESPONSIBILITY to FIX ANY ERRORS that are in
HW#2 in HW#3 or POINTS WILL BE DEDUCTED IN HW#2 AND HW#3 for the same errors.
If you submit HW#2 on time, you will get the grade feedback for it before HW#3 is due.
However, even if the student didn't get the grading feedback yet for HW#2 (for example,
if the student submits HW#3 early before HW#2 was graded, OR if the student submits
HW#2 14 days late, then submits HW#3 the next day without waiting for feedback), any
of the same errors that are in HW#2 and HW#3 will STILL BE DEDUCTED in both!
Write a class called BingoSpot that has an int PRIVATE instance variable for the
value and a boolean PRIVATE instance variable for whether or not it's matched. Include
mutators (setters) and accessors (getters) for each instance variable.
Write a class called BingoCard in which you declare as a private instance variable, a
2-dim. array of BingoSpots (I'm calling it bingoGrid) AND a private instance variable for
the winningNums one-dim. array of ints. In the constructor OR declaration, allocate
memory so the dimensions of the 2-dim. array is 5 X 5. Include the following constructors
or instance methods (NO static METHODS HERE):
a constructor (boolean parameter) that allocates memory for the bingoGrid AND
allocates memory for the winningNums one-dim. array (5 elements) (if not done in the
declaration), AND assigns to each element a new default BingoSpot object. If the
boolean parameter is true, calls fillBingoNums after allocating memory (see below)
default constructor (no parameters) that calls the 1st constructor passing true
public method (fillBingoNums) that has NO PARAMETERS that ALMOST does the
same thing as fillBingoNums() in HW#2, but assigns numbers to the instance variable
bingoGrid's BingoSpot's int values by calling each element's mutator THEN call
initBingoMatches()
public method (initBingoMatches) that has NO PARAMETERS that does ALMOST the
same thing as initBingoMatches() in HW#2, but assigns false to the instance variable
bingoGrid 's BingoSpot's boolean value by calling each element's mutator
public method (findMatch) that has ONLY an int parameter (for the int to try to
match) that does ALMOST the same thing as findMatch in HW#2, but compares the
parameter to this object's bingoGrid 's int value AND as in HW#2, ONLY the column
("row") in which the number should be (NOT the whole 2-dim. array) (also updates the
bingoGrid 's boolean variable if found, AND (to make it easier to debug like in HW#2),
display the row and column where it was found, then returns true if found, otherwise
returns false)
public method (checkWin) that has NO PARAMETERS (returns int []) that does
ALMOST the same thing as checkWin in HW#2, but checks this object's bingoGrid's
boolean variables and if a win is found, fill the winningNums instance variable with the
bingoGrid's int values and return it, or like in HW#2, return null if no win is found)
CIS 35A-- Java Programming
Programming Homework Assignment #3 - Page 2 of 2
public method (displayBingoNums) that has ONLY a String parameter that does
ALMOST the same thing as displayBingoNums in HW#2, but displays this object's
bingoGrid's int values in the similar FORMAT (sideways) as in HW#2
OPTIONAL in the BingoCard class: also declare 2 private instance variable (ints) for
the row and column where a match was found (initialize to -1, and reset to -1 when
you fill the card). These will be assigned in the findMatch method. In the checkWin
method, after checking if these ints are not -1, check ONLY the row for which the
match was found (instead of all rows), and if not a win, ONLY the column for which the
match was found (instead of all columns), and ONLY one of the diagonals if the
element at the row and column is on one of the diagonals.
Write another class called BingoBoard that has a private instance variable (I'm
calling it bingoArray) that's a one-dim. array of boolean, similar to the one in HW#2 AND
a private instance variable (I'm calling it currentNumber) int. In the declaration or default
constructor, allocate memory for 76 elements. Include public instance methods
getBingoNumber and displayCurrentBingoNumber similar to HW#2, except there
are NO PARAMETERS, and currentNumber will be assigned to the return value (in
getBingoNumber) or displayed (in displayCurrentBingoNumber, which could call the static
displayBingoNumber method). Also include a public instance method resetBingoBoard
that will set all the elements in the bingoArray to false. Also include a static
displayBingoNumber that will be EXACTLY like in HW#2.
Write driver class for main, call it Prog3 that is in a separate file and class than
BingoSpot, BingoCard and BingoBoard. Declare in main 2 BingoCard object variables
(I'm calling bingoCard1 and bingoCard2) and a BingoBoard object variable (I'm calling
bingo), and CHANGE main from HW#2 to do the SAME AS IN HW#2, but using only the
main object variables (NO 2-dim. arrays nor one-dim. arrays declared in this class at all!)
ONLY INSTANTIATE EACH OBJECT ONCE passing false for the BingoCard constructor (NOT
in a loop) for EACH object variable! That means in the loop, you will need to call the reset
or fill methods for the objects, but you should NOT call initBingoMatches() because that's
already called in fillBingoNums. This time the playBingo() method will also have a
BingoBoard parameter, as well as the bingoCard1 bingoCard2 as parameters. You will
need to reset the BingoBoard parameter first in the playBingo method, but logic of the
playBingo method MUST be the same as described in HW#2 but using the BingoBoard and
BingoCard parameters. DO NOT USE ANY CLASS-SCOPE VARIABLES in the DRIVER
CLASS (except a static final Scanner for user input) FOR the Prog3 class!
OPTIONAL: Write a BingoGame class that has private instance variables for a BingoBoard
and 2 BingoCard's. Include public INSTANCE methods to fill the instance bingoCards and
display the BingoCards (as in HW#2) (all in one method), and to playBingo which calls the
same methods in the HW#2 main class, but as private instance methods instead (and no
BingoBoard nor BingoCard parameters, but directly access those instance variables).
Turn in with similar input specifications as Prog. HW#2: TURN IN with output that includes
the user winning, the computer winning, someone winning a "row", someone winning a
"column", someone winning a diagonal, and the user quitting before anyone wins. You
may have play several times to get all those examples.
The test runs are the same as for HW#2.
Extra Credit: See the CodeLab exercises for HW#3. See CodeLab for the due dates.