Hi there, i just joined this forum in hope improving my Programming skills.

Currently i have a college assignmnt. It is to create a dice game

"There is a little known dice game which is played with a pair of dice and has the following rules: the player keeps rolling the dice until the total on the dice is 2, 3, 7, 11 or 12. If the total is 7, then the player loses, if it's 2, 3, 11 or 12 then the player wins. If the total is any other number, then the game continues.
Example:
Would you like to play (y/n): y
The dice are:
1 6
The total is 7
Unfortunately, you lost.

Marking scheme says 40% goes for the use of methods, so i was hoping if any of you kind gents/ladies would help me out with this one?

Hello - welcome to the forum. You will be told if you keep posting questions like this that we don't do your homework for you, you need to post code to demonstrate your own effort.

But I'll give you a point in the right direction - assuming that you don't need to use any animations or any methods in the javax.swing library, first focus on getting input from the user and then use this in combination with a while loop, to ensure that it continues to run until the user inputs 'n.'

You will then need to use the math library to get two random number's between, and including, 1 and 6 - see http://www.cs.geneseo.edu/~baldwin/reference/random.html to see how.
Next you need to add these two numbers and check to see if it meets the criteria - i.e. does it add up to 7?

Something like:

int sum = randomOne + randomTwo;

if( sum == 7 )
{
   System.out.println( "You lose!" );
} else if( sum == 2 || sum == 3 || sum == 11 || sum ==12  )
{
  System.out.println( "You win :D" );
} else {
  // Keep going
}

All of the above can be split into methods to keep it all simple and use another class to unite them.
Remember if you don't show any effort no one will want to help you.

@apines, thanks for the link, much appreciated...infact i think the author of the thread you linked me to is in my course!

@katana, thanks for your help too :) PS i wasnt actually looking for someone to do the assignmnent for me, i just wanted some tips as to how i should approach the problem

This article has been dead for over six months. Start a new discussion instead.