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: Im having difficulty with this problem, can someone please help?

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Im having difficulty with this problem, can someone please help?

    Dice are used in many games. One die can be thrown to randomly show a value from 1
    through 6.Design a Die class that can hold an integer data field for a value (from1 to 6).
    Include a constructor that randomly assigns a value to a die object. Appendix D
    contains information on generating randomnumbers. To fully understand the process,
    you must learn more about Java classes and methods. However, for now, you can copy
    the following statement to generate a random number between 1 and 6 and assign it to
    a variable. Using this statement assumes you have assigned appropriate values to the
    static constants.
    randomValue = ((int)(Math.random() * 100) % HIGHEST_DIE_VALUE +
    LOWEST_DIE_VALUE);
    Also include a method in the class to return a die’s value. Save the class as
    Die.java.
    Write an application that randomly “throws” two dice and displays their values.
    After you read the chapter Making Decisions, you will be able to have the game
    determine the higher die. For now, just observe how the values change as you
    execute the program multiple times. Save the application as TwoDice.java.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Im having difficulty with this problem, can someone please help?

    What specific questions do you have about your assignment?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. difficulty with this code
    By ch2207 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 4th, 2013, 08:21 AM
  2. Difficulty with understanding interaction between Classes
    By JBRPG in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 14th, 2012, 07:16 AM
  3. JScrollPane Difficulty. Help Please
    By AceApple in forum AWT / Java Swing
    Replies: 2
    Last Post: June 24th, 2012, 05:30 PM
  4. Difficulty with method headers.
    By tripline in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 30th, 2011, 10:58 AM
  5. [SOLVED] Difficulty with string passing...
    By Destined in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 12th, 2011, 05:43 AM