Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Craps game

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
lowercase baba
Posts: 12856
52
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Marshal
Posts: 15638
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic