Question: Create this project package. Have Candidate class a seperate file within the package. Much appreciated!! in Java :D 1. Create a project called week5lab with

Create this project package. Have Candidate class a seperate file within the package. Much appreciated!! in Java :D

Create this project package. Have Candidate class a seperate file within the

package. Much appreciated!! in Java :D 1. Create a project called week5lab

1. Create a project called week5lab with a main class AbstractElection. 2. (10) In this problem you will create a class called Candidate which will be placed in a file different from that containing the main class but within the same package. A candidate object will have the following private instance variables. e id. Which will be an int and should also be declared final. e numberOfVotes. Which will be a non-negative integer. This should be set to 0 A candidate will have the following public methods. e Candidate which will take an int as argument and set the candi- getId. This method takes no arguments and returns the candidates e get Votes. This method takes no arguments and returns the number e addVote. This method also takes no arguments and simply adds toString. This overrides the method found in class Object. This date's id equal to this. id. of votes that the candidate has gotten. one to the candidates vote total. should return a string which is the id and the number of votes sepa- rated by a comma. 3. (10) Declare the main class to be abstract. The AbstractElection class will have one protected instance variable called candidates and is of type ArrayList, and the following methods, getCandidates. This method will return the ArrayList of candi dates. count Votes. This method is of void type and will be declared ab- stract e get Winner. This method will return the candidate with the most votes. If there is a tie you need only return one of the candidates. This is not abstract and should be implemented in this class. This method needs to execute in O(m) time where m is the number of candidates receiving at least one vote. If candidates is empty return null

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!