Question: Design and implement a test class. This should contain a main method to do the following (23 marks): Write a method that randomly generates an
- Design and implement a test class. This should contain a main method to do the following (23 marks):
- Write a method that randomly generates an odd number of votes in the range 1-10. (3 marks)
- 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)
- Create a list of candidates that consists of the two candidates; Trump and Biden for 2020 US presidential election. (2.5 marks)
- Create a list of US states. Fill in the list of states with hard-coded test data (no user 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)
- For each state, display the candidate list and the state certified winner. At end, announce the overall US Presidential Election Results 2020 for each candidate and the certified winner. (6.5 marks)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
