• Post Reply Bookmark Topic Watch Topic
  • New Topic

better ideas needed  RSS feed

 
John Aris
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have a better way to complete this dice game without using the if loop?


 
Raymond Tong
Ranch Hand
Posts: 255
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try switch block.
http://download.oracle.com/javase/tutorial/java/nutsandbolts/switch.html
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Aris wrote:Does anyone have a better way to complete this dice game without using the if loop?


To be fair, as a side thread, a "better way to complete" implies that the game is complete, and it isn't. Once a point is established, then the rules change and you need to implement the next roll.

Henry
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:Once a point is established, then the rules change and you need to implement the next roll.Henry

just because i'm a pedant...

the rules don't 'change'. The rules for craps are well established before any roll of the dice. Yes, a subset become active and another become inactive, but the rules do not 'change'.

but you are correct that more code is needed.

Also, since I'm in a pedant mode, there is no such thing as an 'If LOOP'. You have an if STATEMENT.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!