Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

If f is a positive function and f''(x)

Answered: 1 week ago

Question

Acceptance of the key role of people in this process of adaptation.

Answered: 1 week ago

Question

preference for well defined job functions;

Answered: 1 week ago