This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Game Development and the fly likes Craps game Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Craps game" Watch "Craps game" New topic
Author

Craps game

Miles Yiengst
Greenhorn

Joined: Feb 08, 2013
Posts: 2
its simple, but i mean it works... right now i only have the pass line bet available, but i'll be adding in other bets later on. its still a fun little game, and i'm just trying to expand it to the full game before the summer.

Miles Yiengst
Greenhorn

Joined: Feb 08, 2013
Posts: 2
if someone could help me out with the continue... it would be much appreciated... right now i just have a big long if statement, and im trying to get it to use less code... thanks
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11441
    
  16

ugghh...no offense, but that is kind of a mess. For starters, you need to learn how to create methods. Most folks around here will tell you your main method should only be a few lines long. For example, you could create a method that computes the next roll. Inside that method, you would get the two random numbers from 1-6, total them, and just return the value. (Granted, this might not work if you want to allow hop bets)

Also, you should check out the java API. Specifically, if you look at the String class and the methods it has pre-built, you can simplify things like your line 93 (equalsIgnoreCase).

You should never write

it is unnecessary, and is prone to mistakes (think about what may happen if you accidentally type (stop = false)...)

just do this:



There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4777
    
    8

fred rosenberger wrote:
just do this:

or better yet:

Fred is right, learn how to use methods to break up the Big Ball of Mud that you currently have.


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Craps game