CSC 222: Object-Oriented Programming
Spring 2013

HW 2: Class Design and Implementation

A common feature of political debates is real time polling, where members of the audience can enter positive and negative responses to debate points, and these responses are aggregated and displayed on the screen as they are entered. For this assignment, you are to design and implement a class that keeps track of an individual viewer's responses during a debate. The viewer enters a response as a real number, either positive or negative, with the number size denoting the intensity of the response. For example, a response of 1.0 might be viewed as a mildly positive response, while 5.0 is an extremely positive response. Similarly, -5.0 might be viewed as an extremely negative response.

A skeleton for the RealTimePoll 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:

Note that getAverage, getMinimum and getMaximum should all return 0.0 if called before any actual responses are recorded.

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 the recordResponse and getAverage methods, making sure that you can record a response and calculate the average. Finally, move on to the getMinimum, getMaximum and reset methods.

Once you have fully tested your class, you can download the file PollGUI.java and add it to your BlueJ project. The PollGUI class defines a graphical user interface (GUI) that allows you to enter responses concerning either debater by dragging a slider, and then see the stats 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 RealTimePoll.java file via BlueLine2.