Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Classes We will be enhancing the classes which we created before (changes in highlighted in yellow), as well as adding new classes for exceptions (this
Classes We will be enhancing the classes which we created before (changes in highlighted in yellow), as well as adding new classes for exceptions (this will hold the custom exceptions we defined). Person (No changes) This will be an abstract class. In this class we have used the concept of inheritance as the candidate class and voter class are child classes so they can access the methods of parent class. Must have the following variables: age (int) - private gender (char) - private, will hold values like M, F, TU firstName (string) - protected lastName (string) - protected political party (string) - protected, will hold values like Democrat, Republican, Non-Affiliate Must have the defined constructor: Person) Person (int age, char gender, String firstName, String lastName. String political party) Which will set the passed properties to our defined variables Will implement the following methods: getAge() - returns int getGender() - returns char Will define the following abstract methods: getFullName() - returns string Candidate This class holds the information about the candidate it will extend the class Person. Must have the following variables: voteCount (int) - private, when the class is instantiated this should default to o Must have the defined constructor: Candidate() Candidate (int age, char gender, String firstName, String lastName. String political party) Which will set the passed properties to our defined variables and super class Throws exception MinimumAgeException if candidate's age is less than 25 The message is "Candidate's age cannot be less than 25" Which will set the passed properties to our defined variables and super class Will implement the following public methods: getVoteCounto - returns int incrementVoteCount() - void, increments the yoteCount getFullName() - returns string o If the candidates firstName = "John" and lastName = "Smith" and political party is Democrat" then it returns "John Smith - D" o If the candidates firstName = "John" and lastName = "Smith" and political party is "Republican" then it returns John Smith - R" o If the candidates firstName = "John" and lastName = "Smith" and political party is "Non-Affiliate" then it returns "John Smith - NA" . Otherwise "John Smith" Voter This class will gather the information about the voter it will extend the class Person. Must have the following variables: Rub voterld (int) - private voted (boolean) - private, when the class is instantiated this should default to false Must have the defined constructor: Voter() Voter (int voterld, int age, char gender, String firstName, String lastName. String political Party) Throws exception MinimumAgeException if voter's age is less than 18 The message is "Voter's age cannot be less than 18" Which will set the passed properties to our defined variables and super class Will implement the following public methods: getVotecido - returns int hasVeted) - returns boolean voted() - void, sets the voted flag to true getFullName() - returns string-eg. firstName = "John" and lastName = "Smith" then it returns "John Smith" Voting Machine This class is used to manipulate and print the results (ie who is the winner and how many votes he/she gained). This class has crucial role in whole system Must have the following variables: candidates (Candidate[]} public, array of all candidates in the race candidates (ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started