Creating a Yahtzee program - Java Help! Core package: Execute the requirements i
ID: 3751662 • Letter: C
Question
Creating a Yahtzee program - Java Help! Core package: Execute the requirements in each class - excluding Yahtzee class and Constants class - each class and package has been created.
Yahtzee class
main() method:
Call static method System.out.println() output to the console “Welcome to Yahtzee!”
Call static method JOptionPane.showMessageDialog() using the method signature that receives two arguments; the first argument should be null, the second argument should be explicit text “Let’s Play Yahtzee!”
constants package
Constants.java
Created/includes:
public final static int MAX_YAHTZEE = 4;
public final static int NUM_DICE = 5;
public final static int MAX_DIE_VALUE = 6;
public final static int>
public final static int TWOS = 2;
public final static int THREES = 3;
public final static int FOURS = 4;
public final static int FIVES = 5;
public final static int SIXES = 6;
public final static int THREE_KIND = 7;
public final static int FOUR_KIND = 8;
public final static int CHANCE = 9;
public final static int NUM_CATERGORY = 13;
public final static int FULL_HOUSE = 25;
public final static int SM_STRAIGHT = 30;
public final static int UPPER_BONUS = 35;
public final static int LG_STRAIGHT = 40;
public final static int YAHTZEE = 50;
public final static int YAHTZEE_BONUS = 100;
core package
AiPlayer.java
Created: Class AiPlayer extends class Player
Override methods from interface IPlayer
1. rollDice()
2. selectCategory()
Die.java
Created: Class Die
Add member variables
1. faceValue, data type int
Create getter/setter for member variable
Game.java
Created: Class Game
Add member variables
1. gameTurn, data type int
2. players, datatype ArrayList
3. dice, datatype class Roll
Create getter/setter for member variables
HumanPlayer.java
Created: Class HumanPlayer extends class Player
Override methods from interface IPlayer
1. rollDice()
2. selectCategory()
IPlayer.java
Created: Interface IPlayer
Add method signatures so that the return type is void and the parameter list is empty
1. rollDice
2. selectCategory
LowerSection.java
Created: Class LowerSection
Add member variables
1. threeKind, data type int
2. fourKind, data type int
3. fullHouse, data type int
4. smStraight, data type int
5. lgStraight, data type int
6 yahtzee, data type int
7. chance, data type int
8. yahtzeeBonus, data type int
9. totalScore, data type int
Create getter/setter for member variables
Player.java
Created: Abstract class Player implements interface IPlayer
Add member variables
1. name, data type String
2. score, data type ScoreCard
Create getter/setter for member variables
Roll.java
Created: Class Roll
Add member variables
1. dice, data type ArrayList
Create getter/setter for member variables
ScoreCard.java
Created: Class ScoreCard
Add member variables
1. upper, data type class UppserSection
2. lower, data type class LowerSection
3. grandTotal, data type int
Create getter/setter for member variables
UpperSection.java
Created: Class UpperSection
Add member variables
1. aces, data type int
2. twos, data type int
3. threes, data type int
4. fours, data type int
5. fives, data type int
6. sixes, data type int
7. totalScore, data type int
8. bonus, data type int
9. total, data type int
Create getter/setter for member variables
Yahtzee class
main() method:
Call static method System.out.println() output to the console “Welcome to Yahtzee!”
Call static method JOptionPane.showMessageDialog() using the method signature that receives two arguments; the first argument should be null, the second argument should be explicit text “Let’s Play Yahtzee!”
constants package
CreatedConstants.java
Created/includes:
public final static int MAX_YAHTZEE = 4;
public final static int NUM_DICE = 5;
public final static int MAX_DIE_VALUE = 6;
public final static int>
public final static int TWOS = 2;
public final static int THREES = 3;
public final static int FOURS = 4;
public final static int FIVES = 5;
public final static int SIXES = 6;
public final static int THREE_KIND = 7;
public final static int FOUR_KIND = 8;
public final static int CHANCE = 9;
public final static int NUM_CATERGORY = 13;
public final static int FULL_HOUSE = 25;
public final static int SM_STRAIGHT = 30;
public final static int UPPER_BONUS = 35;
public final static int LG_STRAIGHT = 40;
public final static int YAHTZEE = 50;
public final static int YAHTZEE_BONUS = 100;
core package
CreatedAiPlayer.java
Created: Class AiPlayer extends class Player
Override methods from interface IPlayer
1. rollDice()
2. selectCategory()
Die.java
Created: Class Die
Add member variables
1. faceValue, data type int
Create getter/setter for member variable
Game.java
Created: Class Game
Add member variables
1. gameTurn, data type int
2. players, datatype ArrayList
3. dice, datatype class Roll
Create getter/setter for member variables
HumanPlayer.java
Created: Class HumanPlayer extends class Player
Override methods from interface IPlayer
1. rollDice()
2. selectCategory()
IPlayer.java
Created: Interface IPlayer
Add method signatures so that the return type is void and the parameter list is empty
1. rollDice
2. selectCategory
LowerSection.java
Created: Class LowerSection
Add member variables
1. threeKind, data type int
2. fourKind, data type int
3. fullHouse, data type int
4. smStraight, data type int
5. lgStraight, data type int
6 yahtzee, data type int
7. chance, data type int
8. yahtzeeBonus, data type int
9. totalScore, data type int
Create getter/setter for member variables
Player.java
Created: Abstract class Player implements interface IPlayer
Add member variables
1. name, data type String
2. score, data type ScoreCard
Create getter/setter for member variables
Roll.java
Created: Class Roll
Add member variables
1. dice, data type ArrayList
Create getter/setter for member variables
ScoreCard.java
Created: Class ScoreCard
Add member variables
1. upper, data type class UppserSection
2. lower, data type class LowerSection
3. grandTotal, data type int
Create getter/setter for member variables
UpperSection.java
Created: Class UpperSection
Add member variables
1. aces, data type int
2. twos, data type int
3. threes, data type int
4. fours, data type int
5. fives, data type int
6. sixes, data type int
7. totalScore, data type int
8. bonus, data type int
9. total, data type int
Create getter/setter for member variables
Explanation / Answer
package yagse_java;
package yagse_java;
public class Die {
private int facevalue;
Die(int i){
facevalue=i;
}
public int getnumber(){
return this.facevalue;
}
public void setnumver(int num){
this.facevalue=num;
}
}
************
package yagse_java;
public class Game {
private int gameTurn;
private double[] players;
private Roll dice;
public int getgame(){
return this.gameTurn;
}
public double[] getplayer(){
return this.players;
}
public Roll getdice(){
return this.dice;
}
public void setgame(int i){
this.gameTurn=i;
}
public void setplayer(double[] player){
this.players=player;
}
public void setdice(Roll k){
this.dice=k;
}
}
********************
package yagse_java;
public interface Iplayer {
void rollDice();
void selectCategory();
}
********************
package yagse_java;
public abstract class Player implements Iplayer{
private String name;
private ScoreCard score;
//write the getter and setter method as shown in previous code//
}
*************************
package yagse_java;
public class ScoreCard {
private UpperSection upper;
private LowerSection lower;
private int Grandtotal;
//implement getter and setter method as shown in previous code//
}
*********************
package yagse_java;
public class UpperSection {
int aces,twos,threes,fours,fives,sixes,totalScore,bonus,total;
//implement getter and setter method as shown in previous code//
}
*****************
public class ScoreCard {
private UpperSection upper;
private LowerSection lower;
private int Grandtotal;
//implement getter and setter method as shown in previous code//
}
*************************************
public abstract class Player implements Iplayer{
private String name;
private ScoreCard score;
//write the getter and setter method as shown in previous code//
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.