Question: Just need VoteList and Driver !!!!!!!!!!!! nums.txt 2, 6, 42789 2, 5, 73106 1, 3, 26828 1, 6, 86356 1, 4, 82325 2, 5, 48116



Just need VoteList and Driver !!!!!!!!!!!!
nums.txt
2, 6, 42789 2, 5, 73106 1, 3, 26828 1, 6, 86356 1, 4, 82325 2, 5, 48116 2, 4, 17988 2, 6, 58931 1, 6, 15315 2, 6, 73844 1, 3, 21326 1, 4, 33165 2, 5, 72274 2, 5, 65527 2, 5, 42249 2, 6, 25722 2, 6, 96433 1, 3, 93663 1, 7, 61046 2, 3, 50041 1, 4, 49526 1, 6, 79890 1, 6, 46645 1, 6, 14032 1, 4, 93557 1, 5, 64567 1, 6, 46163 2, 4, 82380 2, 3, 36106 2, 5, 49440 2, 3, 98777 2, 5, 72069 2, 5, 31771 1, 6, 48420 1, 5, 59298 2, 6, 72703 2, 3, 55959 2, 7, 52921 1, 7, 42000 2, 3, 69951 1, 4, 34200 1, 5, 16274 2, 6, 95457 1, 6, 31432 1, 7, 56337 1, 6, 16326 2, 3, 88504 2, 6, 27021 1, 6, 47060
For Project \#1, you will write a program to determine who has won a recall election! Our program is modeled on the Governor Gavin Newsom recall election of 2021, but you can use fictional candidates instead if you prefer. For this assignment, you should write the following 5 parts: Candidate - An enum with 4 candidates of your choice, plus a 5th option, NONE Vote - 3 instance variables: a boolean recall (where true means "yes, recall"), a Candidate candidate, and int voterID - A 3-argument constructor - Getters for all 3 instance variables - A tostring () that identifies the Vote by voterid and says either "yes" or "no" to the recall, and which candidate they voted for. For example, "Vote 56789 voted yes on the recall and voted for PIKACHU." - You should also copy and insert this equals method directly into your Vote class (when we get to inheritance and polymorphism in class, we'll explain why this is necessary): public boolean equals(Object other ){ boolean same = false; if (other != null \& \& other instanceof Vote ){ same = voterID ==((( Vote) other ) getVoterID ()); return same; Tally. - 2 instance variables: an int votes and a Candidate candidate - A 2-argument constructor - Getters for both instance variables - A tostring () that prints something like "Candidate PIKACHU has 450 votes" VoteList - 2 instance variables: an int count and an ArrayList vlist - a no-argument constructor that sets count to 0 and initializes vlist to an empty ArrayList - addVote (Vote vote), which should add a vote to vlist - but only if vlist doesn't already contain that vote. If the vote is successfully added, count should be incremented and the method should print the tostring () of the vote plus "successfully added". If the vote is not successfully added (because it would be a duplicate), the method should print a message like "Vote 56789 is a duplicate" (in other words, using the voterID of the vote). - printList (), which should print all the Votes in the vlist. - numYesRecall (), which returns an int which is the number of votes that agreed to the recall. - numNoRecall (), which returns an int which is the number of votes against the recall. - isgavinRecalled (), or insert your fictional governor's name instead, which should return a String summary of whether the governor is recalled or not, and says the total number of votes for and against. - tallyCandidates (), which should return an ArrayList. This method should iterate through vlist to count up how many votes went to each candidate. It should also create a Tally object for each candidate, and add each Tally object to a brand new ArrayList. Return this ArrayList. - printCandidatetally (), which should return a String. This method should iterate through the ArrayList that comes from tallyCandidates (), and for each Tally, it should concatenate the tostring () 's, and return the overall String. - getWinningCandidate (), which should return a Candidate. This method should iterate through the ArrayList that comes from tallyCandidates (), and should find the Candidate with the highest votes. That Candidate should be returned. Your Driver class should contain a ma in method but no instance variables or methods. In this ma in method, you should use Scanner to read in this file , nums.txt. Each line should be turned into a Vote, and then added to a VoteList object. Let's see how you should parse each line of your nums. txt file: After turning each line of nums . txt into a Vote object that is added to VoteList, the program should conclude with the following three statements (but note that your isGavinRecalled() method may be differently named, and you might not have called your VoteList object "listvotes"): System.out.println("Will Gavin Newsom be recalled? " + listvotes.isGavinRecalled()); System.out.println("How many votes for each candidate?" + listvotes.printCandidateTally()); System.out.println("Which replacement candidate won the most votes?" + listvotes.getWinningCandidate())
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
