Question: PROGRAMMING IN JAVA - ASSIGNMENT: JAVA CLASSES Instruction: Give java code for a support class called Vote that allows a user to add yes and
PROGRAMMING IN JAVA -
ASSIGNMENT: JAVA CLASSES
Instruction: Give java code for a support class called Vote that allows a user to add "yes" and "no" votes to some total votes, and allows the user to find out which has the higher number. Code class must contain the constructor and methods specified below!
Give code for a support class called Vote that allows a user to add "yes" and "no" votes to some total votes, and allows the user to find out which has the higher number. More specifically, your class must contain the following constructor and methods: A constructor of the form Vote (int yesVotes, int noVotes) This constructor sets the initial number of "yes" votes to yesVotes and the initial number of "no" votes to of the point to novotes. public void yesVote() This method increments the number of "yes" votes by 1. public void noVote() This method increments the number of "no" votes by 1. public String getWinner () This method should return either "yes" or "no", depending on which has the higher total so far. For example: Vote v = new Vote (2, 1); v.yesVote(); Initially 2 "yes" votes and 1 "no" vote Now 3 "yes" votes v.novote (); Now 2 "no" votes System.out.println (v.getWinner ()); Prints "yes"
Step by Step Solution
3.35 Rating (158 Votes )
There are 3 Steps involved in it
Program based on the above question class Vote int yes0no0 public Voteint yesVotesint noVote... View full answer
Get step-by-step solutions from verified subject matter experts
