jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Dice program. Help needed. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Dice program. Help needed." Watch "Dice program. Help needed." New topic
Author

Dice program. Help needed.

dim ch
Greenhorn

Joined: Nov 09, 2005
Posts: 1
Greetings to everyone.

Assume that we have a dice program a very simple one, just prints line of information.
Imagine that we don't want to roll two sixes in any six consecutive roll, how can we do that?



thanks in advance
d.
[ November 09, 2005: Message edited by: dim ch ]
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 6294
    
  15

here are some hints:

1. Keep track of when you last rolled a six.
2. When you roll a six, check how long ago it has been since you rolled the last six. If you think about it, you'll find it's really simple to calculate "how long ago". Only trick is how to set a value for "never". So, if the span between the two sixes is too short, just ignore the last six rolled.


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Dice program. Help needed.
 
It's not a secret anymore!