CSC 222: Object-Oriented Programming
Spring 2012

HW 2: Class Design and Implementation

For this assignment, you are to design and implement a class that keeps score for a basketball team. Your class will allow the user to record free throws, two-pointers, and three-pointers, both missed and made shots. In addition, it should be able to report the score for that team, the shooting percentage of each shot type, and the combined shooting percentage of two- and three-pointers.

A skeleton for the HoopsScorer class is provided for you. It does not contain any fields and the methods are empty (or return a default value if required). You are to add appropriate fields to the class and implement the methods to carry out the designated tasks. The methods are:

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 and test each of the recordMadeShot, recrodMissedShot, and getScore methods, making sure that you can record each type of shot and update the score accordingly. Finally, move on to the getPercentage and reset methods.

Once you have fully tested your class, you can download the file and add it to your BlueJ project. The ScoreBoard 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 void main(String[]).

Submit your file via the Digital Dropbox.