Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

n int wote beol votes and assign the winner respectively. (8 marks for computing votes in WTA state + 15 -L. a) Design and implement

image text in transcribed
image text in transcribed
n int wote beol votes and assign the winner respectively. (8 marks for computing votes in WTA state + 15 -L. a) Design and implement Java classes to represent the following: number 1. Candidate: each object of which represents one candidate, consisting of a name, and the number of electoral and popular votes received by that candidate so far. (7 marks) 2. Using Java Comparator interface, implement necessary classes in order to compare candidate objects on the basis of the data members; the number popular votes or the electoral votes. This would help you to find Collections.max() either based on popular votes or electoral votes. (6 marks: 3 marks for each comparison class) 3. State: each object of which represents one state, consisting of the number of electoral votes allocated for that state, list of candidates and the state certified winner. (10 marks) WTA State: each object of which represents one state type that implements WTA method and it consists of an ArrayList of votes. Each vote consist of a name of the presidential candidate for US. (In 2020 presidential election, votes are for either "Trump" or "Biden"). (3 marks) 5. CDP State: each object of which represents one state type that implements CDP method and it consists of an ArrayList of votes for each CD. (3 marks) Note: In each class, implement constructors and appropriate accessor and mutator methods. Wb) In each state type, define necessary methods to compute the number of popular votes and - the number of electoral votes received by each presidential candidate in one state based on its implemented methodology. Use Collections.frequency() and Collections.max() to count EL Array 3 OTA marks for computing votes in CDP state) c). Redefine the method toString() in the following classes: wp 1. Candidate class to concatenate the state name and the number of popular and electoral votes received by a candidate object. (1 mark) 4 2+0) uut (ada ve 15. For each state, display the candidate list and the state certified winner. At end, 2. State class to concatenate the state name and the number of popular and electoral votes received by each candidate. In addition to the state certified winner details. (4 marks) d) Design and implement a test class. This should contain a main method to do the following (23 marks); 1. Write a method that randomly generates an odd number of votes in the range 1-10. 13 marks) 2. Write a recursive method that fills and returns a list of random votes for either Trump or Biden of length n where n is an odd number. (Call your method in d(1) to get an odd number to be sent as parameter to the recursive fill method). (6 marks) 3. Create a list of candidates that consists of the two candidates; Trump and Biden for 2020 US presidential election. (2.5 marks) 15 4. Create a list of US states. Fill in the list of states with hard-coded test data (no user Art input) from the table above. The states list should hold at least five state objects of any type (WTA and CDP states) where at least one of states is a CDP state. Call your method in d[2) to get a randomly generated votes list for each state or CD. (5 marks) announce the overall US Presidential Election Results 2020 for each candidate and the certified winner. (6.5 marks) syllan Sample run which takes from table 1, the first four states in addition to Nebraska. The state's output was generated from randomly generated votes list: Alabama Candidate Popular votes Trump: 4 Candidate Popular votes Biden 3 Winner Candidate Popular votes Electoral votes 9 Trump out (en) Electoral votes 9 Electoral votes 0 Alaska Candidate Trump Candidate Biden Winner Candidate Blden Popular votes 1 Popular votes 4 Electoral votes 0 Electoral votes 3 Electoral votes Popular votes 4 Electoral votes Arizona Candidate Trump Candidate Wider Winter Popular votes 2 Popular votes Electoral votes 11

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions

Question

=+How might these stem from country and regional cultures?

Answered: 1 week ago