QUESTION

Text
Image

This is all written in Java

This is a two-part assignment.


Instructions: Create a mock election project to demonstrate traversal algorithms to evaluate the results of a mock election with an array and ArrayList. 1. Create a folder called 07.04 Assignment in your Module 07 Assignment folder. 2. Download the Candidate.java to the newly-created folder. a. Observe the class instance variables name and numVotes. b. A constructor is provided. c. Getter and setter methods provided, as well as a tostring method. 3. For this project, you will create two tester classes. One to demonstrate your algorithms with an array and the other for an ArrayList. 4. Create a class called ElectionTesterV1. This will be the tester for the array version. The class needs to contain the following: a. An array containing five Candidate objects with their name and number of votes. b. A method to print the candidate names and votes that traverses through the array and prints out each element. c. A method that traverses through the array and counts the total of the votes for all the candidates. It should return that number. This method will be used by the method to print the table. total number of votes for the election. e. Test your methods. Your output should be similar to that shown below. 5. Now create a class ElectionTesterV2. This class will be the tester for the ArrayList version of the project. Repeat the steps above but this time using an ArrayList.This is the Candidate.java file


public class Candidate
{
// instance variables
private int numVotes;
private String name;

// Constructor for objects of class Candidate
public Candidate(String name, int numVotes)
{
// initialize instance variables
this.name = name;
this.numVotes = numVotes;
}

public String getName()
{
return name;
}

public int getVotes()
{
return numVotes;
}

public void setVotes(int n)
{
numVotes = n;
}

public void setName(String n)
{
name = n;
}

public String toString()
{
return name + " received " + numVotes + " votes.";
}
}
Expected Output: This is a sample of the expected output. The details will vary based on design chcices you make while completing the project.

This is the second part of the Assignment.


Instructions: Create a mock election project to demonstrate traversal algorithms, using the results of a mock election with an arrays and ArrayList. 1. Create a folder called $\mathbf{0 7 . 0 5}$ Assignment in your Module 07 assignments folder. 3. Modify the ElectionTesterV3 program to include the following: a. a method that will find a particular candidate by name and change the name for that candidate. Its arguments should include the array, a name to find, and the replacement name. b. a method that will find a particular candidate by name and change the number of votes for that candidate. Its arguments should include the array, a name to find, and the replacement votes. votes. change occurred. a. change a candidate's name b. change a candidate's vote count c. change a candidate by replacing the name and number of votes 5. Now modify the ElectionTesterV4 class that uses an ArrayList to include the same functionality as the array version.
Expected Output: This is a sample of the expected output. The details will vary based on design choices you make while completing the project.
This is the Grading Rubric for the final program.


ALERT! This rubric covers TWO lessons. You will begin your work now and complete the full assignment in the next lesson. 07.04 Traversals Lesson Grading RubricPlease have all the files separate. since I need to turn in Election Tester v1 and Election Tester v2 as well as Election Tester v3 and Election Tester v4

Public Answer

S1XAQC The First Answerer