CompSci 307 Fall 2022 |
Software Design and Implementation |
This exercise is intended for you to practice developing and debugging inheritance hierarchies. You are also encouraged to use IntelliJ's Debugger to find bugs in the code, as in the previous lab, as well as simply understanding how the unfamiliar code works.
There will not be an official submission for this exercise, instead show your progress to a UTA during lab when you think you are finished to get feedback.
Here is a review of the steps you will use to work with GIT during lab (as distinct from assigned team projects):
lab_pig
into their own repository to allow pushing your group's changes
Settings → Members
to add your partner so both people in the group can access the same repositoryMaintainer
role in the project and choose Add to Project
git clone
to copy the one forked repository to their individual machines so they can work on their own separate copiesOpen
the cloned folder to create a new project on their personal machinegit add
changed files
git commit -m
to describe your changes
git push
changes back to Gitlab
git pull
changes from Gitlab back to the local machine (if you are not sharing a single computer)
For each bug you find:
In pairs, complete the debug the following programs using your forked version of the project. After each, add
, commit
, and push
your changes to the code before continuing on to the next.
Game of Pig
The game of Pig is a point-based dice game in which the first player to score at least 100 points is the winner. This implementation includes a spinner that randomly generates pig noises to supplement the die rolls.
On a player’s turn, they roll a 6-sided die and spin the spinner:
- If the spinner lands on “GRUNT” the player loses all their points for the game so far and their turn is over.
- If the die roll is 1, the player loses the points gained on the current turn only, and the turn is over.
- For any other roll/die combination, the die roll contributes to the points accumulated for this turn.
The player can then decide to play again, risking the turn points, or to "hold" — that is, keep the points for the turn and cede the turn.
There are several bugs in the given code (you do not need to fix them in the order listed here, the numbering is just for reference):
- Game throws a
NullPointerException
in thewinner()
method- Sometimes the spinner gives an
ArrayIndexOutOfBounds
Exception- The die sometimes rolls a 0
- The game does not end when a player gets at least 100 points
- The
ComputerPlayer
’s name gets printed asnull
instead of "R2D2"- Spinning "GRUNT" does not make the player lose all their points
- A 1 and "GRUNT" combination results in the player losing their turn, but not all their point
After each bug you fix, use add
and commit
to "record" your progress through the exercise. Then push
the commits when you are done.
Labs in this course expect you to work either in pairs or with your project team.
Professionally, this practice is called Pair Programming: working closely with another programmer, sharing a "single computer" that we will simulate using a shared computer, shared repository or use IntelliJ's new Code With Me feature. To ensure both people do some coding, you will switch which person actually writes the code every 10-15 minutes (in industry this switch happens only 1-3 times per day). The person who is not actively coding can be advising, suggesting better names, looking up documentation, or searching the Internet for solutions to small problems you are likely to face, but not multi-tasking (i.e., doing their own work or socializing).