CSC 421: Algorithm Design and Analysis
Spring 2015

HW1: Java and Data Structure Review

Note: no late programs will be accepted for this assignment.

For this assignment, you will design and implement a program for scoring a political debate. Each debate viewer is given a board with a dial for each candidate. When a candidate makes a statement that resonates with a viewer, he or she can turn the corresponding dial - in a positive direction if he/she likes the statement or in a negative direction if he/she doesn't. Each turn of a dial is fed into a computer system. For example, consider the following logs of three viewers' reactions:

Tromp -2
Rudio 2.5
Hollery 3
Hollery -3.2
Flanders -0.9
Rudio -1
Tromp -1
Hollery 2.6
Tromp 1
Hollery -1.5
Rudio 4
Tromp 1.1
Hollery 1.5
Rudio -2.0
Flanders 3.3
Tromp 1.0
Tromp -0.5
Flanders -1.5
Hollery 1.8
Rudio 0.1

Each line in the log represents a reaction to a candidate's statement. The first entry on each line is the candidate's name, which you may assume does not contain whitespace. Next is a number between -10 and 10 (with at most one digit to the right of the decimal place), denoting the viewer's reaction. The higher the magnitude (either positive or negative), the more intense the viewer's reaction.

You are to write a program that reads in a series of log file names and produces a table listing the total points, number of positive reactions, and number of negative reactions for each candidate. In addition, the average of the candidate point totals and the total number of positive and negative reactions is listed. For example, assuming the above log files were stored as log1.txt, log2.txt, and log3.txt:

Enter the log file name(s) on a single line: 
log1.txt log2.txt log3.txt

Hollery         4.2        4        2
Rudio           3.6        3        2
Flanders        0.9        1        2
Tromp          -0.4        3        3
                2.1       11        9

Note that the candidates are ordered by the total number of points they received, and the data is organized in columns for readability.

In completing this assignment, you should follow good object-oriented design practices. Any classes that you implement should be cohesive, loosely coupled, and documented using Javadoc comments. Adhering to the Model/View/Controller pattern, all input/output operations should be limited to a driver class, so that the remaining classes could be reused if the interface were to change (e.g., replacing the log files with direct viewer input via a GUI).