Question: How to add the following to my existing code? Java game called yahtzee LowerSection class Add method evaluateCategory() to do the following Access level modifier
How to add the following to my existing code? Java game called yahtzee
| LowerSection class | Add method evaluateCategory() to do the following Access level modifier of public Return type void Parameter listClass Roll Primitive data type int to represent the category the player selected Using conditional logic evaluate which category the player selected Each category should evaluate the face value of each die in class RollIf the face value(s) match the rules of the selected category, call the setter for that category passing the face value or static value as an argument Add method sortDice() to do the followingAccess level modifier private Return type ArrayList only allowing for data type class Integer Parameter list receives an instance of class Roll Instantiate and instance of class ArrayList only allowing for data type class Integer as elements Loop through ArrayListInstantiate and instance of class Integer passing the face value of the die as an argument Add the instance of class Integer to the ArrayList with class Integer as elements Call static method sort() from class Collections passing the ArrayList with instances of class Integer as an argument Return the ArrayList with instances of class Integer Update method setThreeKind() so that it adds to the current value of member variable threeKind (i.e. += versus =) Update method setFourKind() so that it adds to the current value of member variable fourKind (i.e. += versus =) Update method setChance() so that it adds to the current value of member variable chance (i.e. += versus =) Update method getTotalScore() so that it adds together the eight categorys current values |
| ||
| Player class | Update the class to include two abstract methods as definedselectDice() return type void parameter listData type class Roll representing the original instance of the Roll object Data type class Roll representing the dice the player will choose to keep Data type int representing the current roll number of the player calculateScore()return type void parameter listData type class Roll that represents the object reference of the kept dice Data type int representing which category the player selected |
| ||
| Roll class | Add method removeDice to do the following Access level modifier public Return type void Parameter list has one parameter of class Roll Call method removeAll() in class ArrayList for the ArrayList of class Die in class Roll, passing as an argument the ArrayList of class Die in class Roll Update method displayDice to do the followingAdd a local variable of primitive data type int to act as a counter for each die Update the loop that displays the value of each die to includethe counter variable increment the counter |
| ||
| ScoreCard class | Update class to do the followingAdd a custom constructor to do the following Instantiate the member variable of class UpperSection Instantiate the member variable of class LowerSection Update method getGrandTotal to do the followingSet member variable grandTotal equal to the call to methodsgetTotal() in class UpperSection added to getTotalScore() in class LowerSection |
| ||
| UpperSection class | Add method evaluateCategory() to do the following Access level modifier of public Return type void Parameter listClass Roll Primitive data type int to represent the category the player selected Using conditional logic evaluate which category the player selectedEach category should evaluate the face value of each die in class RollIf the face value matched the selected category, call the setter for that category passing the face value as an argument Update method setAces() so that it adds to the member variables current value the parameter received (i.e. += versus =) Update method setTwos() so that it adds to the member variables current value the parameter received (i.e. += versus =) Update method setThrees() so that it adds to the member variables current value the parameter received (i.e. += versus =) Update method setFours() so that it adds to the member variables current value the parameter received (i.e. += versus =) Update method setFives() so that it adds to the member variables current value the parameter received (i.e. += versus =) Update method setSixes() so that it adds to the member variables current value the parameter received (i.e. += versus =) Update method getTotalScore() so that it adds together the six categorys current values Update method getScore() so that it adds together the member variable totalScore and bonus | package core; public class UpperSection { private int aces; private int twos; private int threes; private int fours; private int fives; private int sixes; private int totalScore; private int bonus; private int total; public int getAces() { return aces;} public void setAces(int aces) { this.aces = aces;}public int getTwos() { return twos;} public void setTwos(int twos) { this.twos = twos;} public int getThrees() {return threes;} public void setThrees(int threes) { this.threes = threes;}public int getFours() {return fours;} public void setFours(int fours) {this.fours = fours;} public int getFives() {return fives;} public void setFives(int fives) {this.fives = fives;} public int getSixes() {return sixes;} public void setSixes(int sixes) {this.sixes = sixes;} public int getTotalScore() {return totalScore;} public void setTotalScore(int totalScore) { this.totalScore = totalScore;}public int getBonus() {return bonus;} public void setBonus(int bonus) {this.bonus = bonus;} public int getTotal() {return total;} public void setTotal(int total) {this.total = total;}} |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
