How to implement YAHTZEE game in java using switch statements?
I have to create a source code in JAVA for scoring in the game Yahtzee
I have no idea where to start
It has to have a switch statement and if-else statements
here is what I have so far
Code java:
public class Yahtzee {
// constants that specify categories on the scoresheet
public static final int ONES = 1;
public static final int TWOS = 2;
public static final int THREES = 3;
public static final int FOURS = 4;
public static final int FIVES = 5;
public static final int SIXES = 6;
public static final int THREE_OF_A_KIND = 9;
public static final int FOUR_OF_A_KIND = 10;
public static final int FULL_HOUSE = 11;
public static final int SMALL_STRAIGHT = 12;
public static final int LARGE_STRAIGHT = 13;
public static final int YAHTZEE = 14;
public static final int CHANCE = 15;
/**
* Calculates the score for a given turn.
*
* @param category selected by the player
* @param dice current values of the dice
* @return number of points, or 0 if N/A
*/
public static int calculateScore(int category, Dice dice) {
int die1;
int die2;
int die3;
int die4;
int die5;
die1 = (int)(Math.random() * 6) + 1;
die2 = (int)(Math.random() * 6) + 1;
die3 = (int)(Math.random() * 6) + 1;
die4 = (int)(Math.random() * 6) + 1;
die5 = (int)(Math.random() * 6) + 1;
int score;
score = 0;
switch(score)
{
case ONES:
break;
case TWOS:
break;
case THREES:
break;
case FOURS:
break;
case FIVES:
break;
case SIXES:
break;
case THREE_OF_A_KIND:
break;
case FOUR_OF_A_KIND:
break;
case FULL_HOUSE:
break;
case SMALL_STRAIGHT:
break;
case LARGE_STRAIGHT:
break;
case YAHTZEE:
break;
case CHANCE:
break;
return score;
}
}
public static int oneValue(int value, Dice dice) {
return 0;
}
public static int threeOfAKind(Dice dice) {
return 0;
}
public static int fourOfAKind(Dice dice) {
return 0;
}
public static int fullHouse(Dice dice) {
return 0;
}
public static int smallStraight(Dice dice) {
return 0;
}
public static int largeStraight(Dice dice) {
return 0;
}
public static int yahtzee(Dice dice) {
return 0;
}
public static int chance(Dice dice) {
return 0;
}
}
Re: SERIOUS HELP YAHTZEE JAVA SOURCE CODE
First off, please use highlight tags when posting code to preserve formatting.
Secondly, I recommend you start by reading this: Starting Writing a Program