Question
(C#) Create an Election class that has number of registered voters, number of votes cast, and a list of candidate names. Use properties for the
(C#) Create an Election class that has number of registered voters, number of votes cast, and a list of candidate names. Use properties for the first and second. For the list of candidates, create an add candidate method that accepts a string and a get candidate method that accepts an integer. For example: anElection.GetCandidate(5) gets the 5th candidate. Make each property and the GetCandidate methods do error checking. Do error checking and throws in the Election class. Some "errors" may not be obvious so put on your "thinking cap". In main, test to make every throw statement in the Election class execute then, in main, catch and display appropriate messages explaining to the user of the program what happened.
For example: Election anElec = new Election(); anElec.AddCandidate("Alice"); anElec.AddCandidate("Betty"); anElec.AddCandidate("Carol"); //anElec.GetCandidate(5); // try this then comment it out to try next one //anElec.RegisteredVoters = -1; anElec.NumberVotes = 10;
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