Results 1 to 2 of 2
  1. #1
    thenewsaw is offline Member
    Join Date
    Feb 2009
    Rep Power

    Unhappy RAndom role dice

    * The Dice class models rolling a regular six-sided die

    import java.util.Random;

    public class Dice {

    /** instance variables */
    private Random r;

    * Initializes the random number generator r
    public Dice() {


    * Returns a random integer between 1 and 6 using Random r
    public int roll() {



    This is the code given by my instructor. I'm trying to fix this up by i can't. I am a beginner in this field. can anybody help me with this? please e-mail me in this add

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Rep Power

    Default wrong sub-forum...

    • First, this is not the correct sub-forum (JCreator). This should be in the "New to Java" sub-forum. I'll let the moderators move it.
    • Second, nobody is going to do your homework for you and much less send it to you in an email. The forum will help you with specific problems, but it will not do your homework for you.
    Back to your problem .... you have been given a skeleton code to work with. Sorta like filling in the blanks.... and the instructions are given too you as what you have to put in each part. A couple of things....

    1) You have to become familiar with the Random class (it's easy).

    2) The class you're working on does not have a main method, therefore it will have to be called by another class that does have a main method. You can worry about that when the above is understood.

    Read the links above. When you have finished, try to apply that knowledge to your program. Any questions or doubts, just let us know.

    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. Replies: 8
    Last Post: 04-19-2009, 05:50 PM
  2. Defective code for dice, help please?
    By byron in forum New To Java
    Replies: 10
    Last Post: 04-01-2008, 06:22 AM
  3. Java Web Developer - Permanent Role - Swindon
    By Mike Brown in forum Jobs Offered
    Replies: 0
    Last Post: 02-12-2008, 04:21 PM
  4. random numbers without random class`
    By carlos123 in forum New To Java
    Replies: 4
    Last Post: 01-17-2008, 10:44 PM
  5. Help debugging a dice game
    By Windoze in forum New To Java
    Replies: 7
    Last Post: 11-22-2007, 01:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts