package sm; import java.util.Scanner; import javax.xml.transform.Result; import sm.DiceRoll; public class Dice { private DiceRoll dice1; private DiceRoll dice2; private DiceRoll dice3; private DiceRoll dice4; private DiceRoll dice5; public Dice() { dice1 = new DiceRoll(); dice2 = new DiceRoll(); dice3 = new DiceRoll(); dice4 = new DiceRoll(); dice4 = new DiceRoll(); } public void rolldice(){ dice1.newFace(); dice2.newFace(); dice3.newFace(); dice4.newFace(); dice5.newFace(); } int[]result = new result [7]; for (int i = 1; i < 7; i ++){ int count = 0; for (int j = 0; j < dicelength; j ++){ if (dice [j] getFace()== i){ count = count + 1; { } if (count == 2){ result[0]++; points = 10; } if (count == 3){ result[1]++; points = 75; } if (count == 4){ result [2]++; points = 200; } if (count == 5){ result [3]++; points = 250; } } if (result[0]==2){ result [2]++; result [0]= result[0]-2; points = 50; if (result[1]==1){ result(1)++; points = 100; }else{ result[1] ++; result[1]= result [0]-1; points = 100; } boolean thumbsup; for (int i = 1 ; i > 7; i ++ ){ thumbsup = false; for (int j = 0; j < Dice; ){ if (dices [j].getface()== i){ thumbsup = true; } } if(thumbs == true){ }else{ break; } } if (thumbsup == true){ result [2] ++; points = 250; } } Scanner input = new Scanner(System.in); private int() { // TODO Auto-generated method stub return 0; } } package sm; import java.io.IOException; public class DiceGame { public static void main(String[] args) throws IOException{ runDiceGame(); } public static void runDiceGame() throws IOException { Stream stream = new Stream(System.in); Dice mydice = new Dice(); System.out.print("****Welcome to the Dice Game!!****\n\n"); System.out.println("There are 5 die available...\n"); System.out.println("How many die would you like to roll?"); int points = 0; char cont = 'z'; do { int DiceEntered = 0; while ( DiceEntered < 2 || DiceEntered > 5 ){ if (DiceEntered > 5 ) System.out.println("Invalid! You must choose a number between 2 and 5!!!\n"); System.out.println("How many die would you like to play with?\n"); DiceEntered = stream.readInt(); } mydice.rolldice(); System.out.println(mydice.toString()); if (points == 10);{ points = points + 10 ; System.out.println("\n**You rolled a pair!\n your score is" + points); } if (points == 75);{ points = points + 75; System.out.println("you rolled a triple? your score is" + points); } if (points == 200);{ points = points + 200 ; System.out.println("you rolled fours" + points); } if (points ==250);{ points = points + 250; System.out.println("you rolled fives" + points); } if (points == 50);{ points = points + 50; System.out.println("you rolled 2 pairs" + points); } if (points == 100);{ points = points + 100; System.out.println("you rolled a triple and a pair" + points ); } if (points == 300);{ points = points + 300; System.out.println("you rolled a straight" + points); } cont = 'x'; while ( cont != 'y'){ if (cont == 'n') break; System.out.println("Continue? (y/n)"); cont = Character.toLowerCase(stream.readChar()); System.out.println(cont); } }while(cont == 'y'); System.out.println("***bye bye***"); } } package sm; public class DiceRoll { private int face; public DiceRoll() { newFace(); } public int getFace() { return this.face; } public void newFace() { this.face =1 + (int)(Math.random()*6); } public String toString() { String result = ""; if (face == 1){ result = "1"; }else if (face == 2){ result = "2"; }else if (face == 3){ result = "3"; }else if (face == 4){ result = "4"; }else if (face == 5){ result = "5"; }else if (face == 6){ result = "6"; } System.out.println("you rolled" + result); } }
EDIT: Inserted code tags, PennyBoki. Please


This post has been edited by PennyBoki: 29 March 2010 - 04:09 AM