Skip to content

Commit 6217596

Browse files
author
Fuad Mohamoud
committed
Create README.md
1 parent 4a11ddf commit 6217596

File tree

1 file changed

+182
-0
lines changed

1 file changed

+182
-0
lines changed

README.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# JavaClassProject-2
2+
CSCI161 Second Java Project Completed
3+
4+
5+
This was my Second project of the Spring 2016 Semester and I learned alot of new programming concepts. In this Project I utilized Inheritance, Exception handling, method overloading and overriding along with re-learning a valuable skill: Good Variable names and great documentation. Below are the list of requirements the program must adhere by in order to get a perfect score on the project.
6+
7+
I have provided a sample txt file if you wish to download the program, all that needs changing is the scanner directory in the Driver file for the program to work.
8+
9+
10+
11+
12+
List of Requirements:
13+
14+
15+
Candidate
16+
17+
Needs a toString() method.
18+
Needs an equals() method (compares candidate name)
19+
Needs a compareTo() method (Compares candidate’s money)
20+
Has an Advertisement preference. (Generate this value randomly from the 3 options)
21+
The 3 types of Advertisements are: Issue-Based, Attack Ads, Town Hall
22+
Has a Fundraiser preference. (Generate this value randomly from the 3 options) The 3
23+
types of Fundraisers are: Social Events, Automated Phone Calls, Political Action Committees.
24+
Has a money modifier (initially 1.0 when the Candidate is created):If this value is every below zero, the associated get method should return zero.The associated set method should add to or subtract from the current value by
25+
the input parameter value
26+
Has a debate modifier (initially 1.0 when the Candidate is created):If this value is every below zero, the associated get method should return zero. The associated set method should add to or subtract from the current value by
27+
the input parameter value
28+
The old endorsement method should now take in an Advertisement. Based on the
29+
Advertisement, the endorsement method should return a Boolean value to indicate if
30+
the Candidate approved the Advertisement.
31+
32+
Debate
33+
34+
Needs a toString() method.
35+
Can now have 2 or more candidates (capped at max integer)
36+
Winner should now be decided by:
37+
Generating a debate score for each candidate involved in the debate.
38+
Use the formula, where Random_Number is 0 to 100 (both endpoints inclusive):
39+
Debate_Score = Random_Number * Candidate’s_Debate_Modifier
40+
Candidate with highest debate score wins!
41+
Winning candidate receives money from each losing candidate as calculated by:
42+
Money_Won = Losing_Candidate’s_Money * (Total_Of_All_Debate_Scores -
43+
Losing_Candidate’s_Debate_Score ) / Total_Of_All_Debate_Scores
44+
Return String declaring the winner and how much money each losing candidate
45+
lost to the Winner
46+
47+
Fundraiser
48+
49+
Needs a toString() method.
50+
Should now generate money by:
51+
Randomly generating a number of donors who attended (0 to 200, both points
52+
inclusive)
53+
For each donor, generate a random number (0 to 151, zero inclusive, 151
54+
exclusive) to represent how much that donor contributes
55+
Total of all donations should be multiplied against the candidate’s money
56+
modifier
57+
Add the resulting value to the candidate’s money
58+
59+
Election
60+
61+
Needs a toString() method.
62+
Should now allow any number of Candidates to enter
63+
64+
NEW OBJECTS SECTION:
65+
66+
Advertisement
67+
68+
Should have a message which describes what the Advertisement is about
69+
Has a Candidate
70+
Have a cost
71+
o Needs a toString() method.
72+
73+
74+
IssueBasedAdvertisement
75+
76+
Needs a toString() method.
77+
Should be a sub-class of Advertisement
78+
Cost should be randomly generated between 5,000 and 20,000 (endpoints inclusive) If approved by its Candidate, it should:
79+
Increase its Candidate’s debate modifier by .1 unit.
80+
Return Endorsement message (see OoL #1 for exact text). If not approved by its Candidate, it should:
81+
Increase its Candidate’s debate modifier by .05 units.
82+
Return the message “This message has not been approved by XXX.” Where XXX
83+
should be replaced by the name of the candidate.
84+
85+
86+
AttackAdvertisement
87+
88+
Needs a toString() method.
89+
Should be a sub-class of Advertisement
90+
Cost should be randomly generated between 50,000 and 75,000 (endpoints inclusive) o Should have a second candidate (referred to in this specification as the TARGET)
91+
If approved by its Candidate, it should:
92+
Increase its Candidate’s debate modifier by .2 units.
93+
Decrease its Candidate’s money modifier by .2 units.
94+
Decrease its TARGET’s debate modifier by .15 units.
95+
Decrease its TARGET’s money modifier by .25 units.
96+
Return Endorsement message (see OoL #1 for exact text).
97+
If not approved by its Candidate, it should:
98+
Increase its Candidate’s the debate modifier by .1 unit.
99+
Decrease its Candidate’s the money modifier by .05 units.
100+
Decrease its TARGET’s debate modifier by .05 units.
101+
Decrease its TARGET’s money modifier by .1 units.
102+
Return the message “This message has not been approved by XXX.” Where XXX
103+
should be replaced by the name of the candidate.
104+
105+
TownHallAdvertisement
106+
107+
Needs a toString() method.
108+
Should be a sub-class of Advertisement
109+
Cost should be randomly generated between 5,000 and 100,000 (endpoints inclusive) o Has attendees
110+
Attendees should be generated randomly as follows:
111+
Generate a random number from 0 (inclusive) to 151 (exclusive) o If approved by its Candidate, it should:
112+
Increase its Candidate’s money modifier by (attendees / 500.0) units
113+
Return the message “XXX holds a successful Town Hall.” Where XXX should be
114+
replaced by the name of the candidate. o If not approved by its Candidate, it should:
115+
Increase its Candidate’s money modifier by (attendees / 2000.0) units
116+
Return the message “XXX holds a Town Hall.” Where XXX should be replaced by
117+
the name of the candidate.
118+
119+
SocialFundraiser
120+
121+
Needs a toString() method.
122+
Should be a sub-class of Fundraiser
123+
During money generation and after money has been transferred to Candidate:
124+
Candidate’s money modifier should be increased by .1 units
125+
126+
PhoneFundraiser
127+
128+
Needs a toString() method.
129+
Should be a sub-class of Fundraiser
130+
During money generation and after money has been transferred to Candidate:
131+
Candidate’s money modifier should be decreased by .05 units
132+
133+
PACFundraiser
134+
135+
Needs a toString() method.
136+
Should be a sub-class of Fundraiser
137+
During money generation and after money has been transferred to Candidate:
138+
Candidate’s money modifier should be increased by .2 units
139+
Candidate’s debate modifier should be increased by .1 units
140+
141+
OutOfMoneyException
142+
143+
This exception should be thrown during an advertisement’s constructor if the ad will cost more than the Candidate has money.
144+
145+
TooLowInPollsException
146+
147+
This exception should be thrown during a debate’s constructor if a one or more of the
148+
debate’s candidate has less than 3% of the total money currently in play (total of all money from all candidates) UNLESS all of the debate’s candidates are from the same political party
149+
This exception should be thrown during a PACFundraiser’s constructor if the PACFundraiser’s candidate has less than 1% of the total money currently in play (total of all money from all candidates)
150+
151+
DRIVER LAYOUT: The Driver will now operate as follows:
152+
153+
Should read in a file with candidate data for all candidates. Your only guarantee about file size is that there will be between 1 and Max Integer candidates. The input file will still be formatted the same way as OoL #1
154+
Use the candidate data to create your candidates (must use either an Array or ArrayList of Candidates)
155+
Read in location data from a file called “Locations.txt” (There will be one location per line in this file)
156+
Store the location data in an Array or an ArrayList
157+
Run through a loop 365 times. Each iteration = 1 day. Each time through this loop:
158+
Each Candidate will be allowed 1 action, the action should be randomly selected from: Fundraising (30% weighted UNTIL day 250, then 60% weighted):
159+
Create a Fundraiser of the Candidate’s preferred type (and select its location randomly from the list of locations)
160+
If a TooLowInPollsException was triggered, randomly select and create either of the non-PACFundraisers instead.
161+
Use the Fundraiser to generate money
162+
Printout the fundraiser’s information via the Fundraiser’s toString() Advertising (70% weighted until day 250, then 40% weighted)
163+
Generate a random Advertisement from the 3 specific types of Advertisements
164+
If an OutOfMoneyException was triggered, do a fundraising event instead
165+
Printout the Advertisement’s information and effects via the Advertisement’s toString();
166+
167+
If the current day is evenly divisible by 10:
168+
And day 305 hasn’t been reached yet:
169+
Create a debate for each political party
170+
Each of political party’s debate should include all candidates from that
171+
political party
172+
Location data should be randomly selected from the list of locations
173+
Declare the winner of the each debate and printout each debate’s
174+
information using the debate’s toString() After day 305:
175+
Create 1 debate which includes all eligible Candidates (candidates with more than 3% of the total money currently in play (total of all money from all candidates))
176+
Location data should be randomly selected from the list of locations
177+
Declare the winner of the debate and printout the debate’s information
178+
using the debate’s toString()
179+
Printout each of the Candidates (using their toString()) from most money to least money
180+
Create an election using all candidates
181+
Determine who won the election
182+
Print the String announcing who won the election using the election’s toString()

0 commit comments

Comments
 (0)