File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Dice Poker program: Re-rolling the dice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Dice Poker program: Re-rolling the dice" Watch "Dice Poker program: Re-rolling the dice" New topic
Author

Dice Poker program: Re-rolling the dice

Shahan Kemanjian
Greenhorn

Joined: Mar 23, 2013
Posts: 1
I have a project in which I need to create a Dice Poker game, also I am VERY new to programming so I am still trying to get my footing when it comes to this. In the game the user rolls 5 dice, then is asked if he/she would like to re-roll any of the dice along with which ones (#'s 1-5). I was able to do the first roll by setting it to an array, but I am completely lost when trying to figure out how to do the re-roll. Any suggestions on how the user can choose which dice to roll again and then having the new numbers replace the older ones? This is the code for the first dice roll.

Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8427
    
  23

Shahan Kemanjian wrote:This is the code for the first dice roll...

And therein lies your problem. You've already written code before you've worked out how to solve the problem.

So, my advice: StopCoding (←click), and go back to your problem description:
"In the game the user rolls 5 dice, then is asked if he/she would like to re-roll any of the dice along with which ones (#'s 1-5)."

One tip for you though: Java is an Object-oriented language, so it generally works best when it has objects to work with; but you've equated a die with an int. Now, I can understand why you did that; but it's not really the best start.
This page, although it talks about Strings rather than ints, may help to explain why.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dice Poker program: Re-rolling the dice