Comp 152 Project 2

Due: Wednesday  Feb 24th at 11:55pm

Summary and goals:

In this project you will have another chance to use ArrayLists since I got several last minute emails saying several of your were still shaky about them. You will also use UML to help develop your project more readily.


Details:

Write a program with three classes and the enum as seen in the UML diagram below. This program will simulate the electoral college in the elections this decade.

UML class diagram for project 2


Implementation Specification:

Party: This is an enumerated type with three possible values (in alphabetical order): Democrat, Independent, Republican

State:
This class encapsulates a state in the electoral college. It has three instance variables which should be initialized by the three parameters to the constructors. The other three methods are all accessors which retrieve the value of the associated instance variable.

ArrayList<State>: this is the standard ArrayList in the Java.util package.

Electorial College:
    In the constructor first create the stateVotes instance variable. Next open the file Electoral201X.txt and read out the state names and the number of electoral votes for each state. Use a java.util.Random object to assign the state to one of the three parties for the Party Enum. Lets say that Democrats and Republicans should each have a 2 in 5 chance of winning. The independent should have a one in 5 chance of winning. Create the resulting State object and store it in stateVotes. Do this for all 50 states (plus the district of Columbia).
In announceWinner() look through stateVotes and add up the total electoral votes for each of the three parties. Print out the total electoral votes for each party and if any party has more than the 270 needed to win, announce that party as the winner - otherwise announce that Congress will have to make the choice. Finally, print the individual winner of each state.


VoteTester: This class contains only the main method. The main method should create an ElectoralCollege object and then call announceWinner on that object.


You must have all of the methods and instance variables specified in the UML. You may have any additional methods that you wish to make the project easier to implement.

Readme:

You also need to have a readme.txt file in your folder which contains


Submission:


Include a readme.txt text file in your project. For this project the readme.txt should include

When you are ready to submit your project zip up the folder with the java code, the text input file and your readme and upload them to moodle.