Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Making a Craps game.

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Making a Craps game.

    Hey All,

    I am new to Java. I have a 2 phase assignment to make a craps game. In the first phase I have to implement two classes, Die and PairOfDice. The public methods of Die are Die(), int getTopValue() and void roll(). The public methods for PairOfDice are PairofDice(), int GetValue() and void roll().

    The implementation of the PairOfDice class must use two Die objects. It must not make direct use
    of the Random class.

    I am just not quite sure where to start. Any ideas and hints would be appreciated.


  2. #2
    Junior Member
    Join Date
    Mar 2010
    Posts
    14
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Making a Craps game.

    In the first phase I have to implement two classes, Die and PairOfDice. The public methods of Die are Die(), int getTopValue() and void roll()
    A good place to start would be to write out a skeleton for your class, Die. Write the class definition for Die, define its member variables* and methods. You can leave the bodies of the methods empty for now as you think about what to put in them.

    *You didn't mention member variables, but I can think of at least one you are going to want.

    For example, say I wanted to write out a skeleton of code for a class called Test. Test has the following methods: Test(), int getValue(), void setValue(int x). It also as a int member variable, value. My stubbed out code would look like:

    class Test {
      // Test's member variables.  These keep track of the current state of a Test instance.
      int value;
     
      Test() {
        // Fill me in later!
      }
     
      int getValue() {
        // Fill me in later!
      }
     
      void setValue(int x) {
        // Fill me in later!
      }
     
    }

    Now let's see what you come up with for your Die class. You can start filling in the methods if it become apparent what they should accomplish. Or, if you don't know how to accomplish it in code, but know what you want the methods to do, write it out in comments inside the method body.

Similar Threads

  1. Error in Program for Game of Craps
    By TheAsianMenace in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 23rd, 2010, 04:31 AM
  2. Game of Craps: won't compile
    By FreeBird in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 15th, 2010, 05:12 PM
  3. Theory behind 2d Game making?
    By DarrenReeder in forum Java Theory & Questions
    Replies: 3
    Last Post: January 28th, 2010, 02:54 AM
  4. Craps- GAME fine tunning.
    By Beaney in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 3rd, 2010, 08:32 PM
  5. Problem while programming a simple game of Car moving on a road
    By rojroj in forum Java Theory & Questions
    Replies: 3
    Last Post: April 2nd, 2009, 11:24 AM