PROJECT 10a author version 20141010 package project10 import java util Scanner public class project10a public static void main String args private static void resetDice int dice for int i 0 i dice length i dice i 0 private static void rollDice int dice for int i 0 i dice length i if dice i 0 dice i int Math random 6 1 private static String diceToString int dice String res for int i 0 i dice length i res dice i return res private static void promptForReroll int dice Scanner inScanner int roller while true System out println Enter which die should re rolled roller inScanner nextInt if roller 1 return if roller dice length 1 roller 1 System out println Invalid roller index continue dice roller 0 private static boolean promptForPlayAgain Scanner inScanner String response while true System out println Do you want to play again Y N response inScanner next if response equalsIgnoreCase Y return true else if response equalsIgnoreCase N return false else System out println Invalid response try again private static String getResult int dice int counts getCounts dice String resValue for int i 0 i counts length i if counts i 5 resValue Five of a kind else if counts i 4 resValue Four of a kind else if counts i 3 for int j 0 j counts length j if counts j 2 resValue Full House resValue Three of a Kind else if counts i 2 for int j 0 j counts length j if counts j 2 resValue Two Pairs resValue One Pair else resValue Highest Card return resValue private static int getCounts int dice int counts new int 0 String resValue for int i 0 i dice length i if dice i 1 counts 0 else if dice i 2 counts 1 else if dice i 3 counts 2 else if dice i 4 counts 3 else if dice i 5 counts 4 else if dice i 6 counts 5 return counts
View Full Document