Question: Create a system with three classes: 1. Create a Candidate class ( Candidate.java ) with four private fields: firstName, lastName, party, and trustworthy (with types:

Create a system with three classes:

1. Create a Candidate class (

Candidate.java

) with four private fields: firstName,

lastName, party, and trustworthy (with types: String, String, char, and boolean,

respectively).

o

Create a single constructor that accepts parameters for first name, last name,

party, and trustworthy.

o

The first name and the last name are read only. The other two fields have both

accessors and mutators.

2. Create an Election class (

Election.java

) that manages a list of all candidates in the

upcoming election.

o

This class should have a private field, of type array, that will hold all of the

candidates.

o

Provide a single constructor that accepts no parameter, and creates a

Candidate array with size of 0.

o

Provide support to add a candidate.

o

Provide support to display all candidates.

3. Create an ElectionTest class (

ElectionTest.java

) with two methods:

o

main (the standard entry point) should call a private method createElection

(see below), and then display all candidates in the election.

o

createElection() should return an Election object:

?

Create an Election object.

?

Create at least three Republican (R) candidates with only the first one

being trustworthy and add each to the election.

?

Create at least three Democrat (D) candidates with only the first one

being trustworthy and add each to the election.

The output should look similar to the following:

Some of the major candidates in the upcoming election are:

First Name

Last Name

Party

Trustworthy

--------------------------------------------

Donald

Trump

R

true

Ben

Carson

R

false

Jeb

Bush

R

false

Hillary

Clinton D

true

Bernie

Sanders D

false

Jim

Webb

D

false

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!