For this assignment, you are to extend the functionality of the
class that was developed as an in-class exercise. As we originally defined it,
ScoreKeeper class had methods for specifying a made basketball shot (either
a 3-point field goal, a 2-point field goal, or a 1-point free throw) and also a method for
accessing the current score. For this assignment, you will need to extend the
functionality of this class so that:
madewill serve to record any made shot, with a parameter specifying which type of shot was made (either 1, 2, or 3 points). For example, given a
scorer, the call
scorer.made(3)should record a made 3-pointer, resulting in the score being increased by 3.
missedwill record a missed shot of any of the three types. For example, the call
scorer.missed(1)should record a missed free throw.
getPercentwill return the percentage of made shots for a specified type of shot. For example, the call
scorer.getPercent(2)should calculate and return the percentage of 2-point field goals made. Note that the percentage should be a real number between 0.0 and 100.0, rounded to a single digit to the right of the decimal place.
resetwill reset the score and all related statistics to 0, allowing for a new game to be tracked.
The javadoc file ScoreKeeper.html gives a full description of the class and the exact form that the methods must take. Your class implementation should include comments (both at the top of the class and at each method) so that BlueJ's interface view would produce a similar page.
It is strongly recommended that you develop and test your class in stages. For example,
first specify the fields and constructor, then use BlueJ to create an object and inspect
its fields to make sure they are correct. Next, implement the
getScore methods, making sure that you can record each type of made shot
and update the score accordingly. Finally, move on to
Once you have fully tested your class, you can download the file
and add it to your BlueJ project. The
ScoreGUI class defines a graphical
user interface (GUI) that allows you to select a missed or made shot at the click of
a button, and then see the score and percentages automatically updated.
Once you have compiled this class, you can open up an interface window by
right-clicking and selecting
ScoreKeeper.javafile via the Digital Dropbox.