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 4 of 4

Thread: Need some assistance please

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Need some assistance please

    /************************************************** ************
    Not sure if my second constructor is working properly please help. It is intended to be copy and used to sort the die in yahtzee so i could use it for checking 3 of a kind. 4 of a kind. 5 of a kind. Yahtzee. and full house on a different java class.
    ************************************************** ************/
    public class Dice
    {
    Die [] dice;
    Random gen;

    /************************************************** ************
    The constructor uses a random generator to build each die.
    The number of Die objects is passed as a parameter.
    @param gen The random generator
    @param num The number of die objects
    ************************************************** ************/
    public Dice(Random gen, int num)
    {
    this.gen = gen;

    dice = new Die[num];
    for (int ii = 0; ii < dice.length; ii++)
    {
    dice[ii] = new Die(gen);
    }
    }
    /************************************************** ************
    This copy constructor returns an identical set of dice to
    the parameter. This is used to create a set of dice whose
    order can be changed from the original.You should use the
    Die constructor that creates a die with the same face value
    as the original for each of the Die in the set.

    @param dice The Dice object to copy
    ************************************************** ************/
    public Dice(Dice dice)
    {

    for(int ii = 0; ii < dice.getSize(); ii++)
    {
    this.dice[ii] = new Die(new Random());
    }
    // check me
    }


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Need some assistance please

    Quote Originally Posted by JavaPhish View Post
    /************************************************** ************
    Not sure if my second constructor is working properly please help. It is intended to be copy and used to sort the die in yahtzee so i could use it for checking 3 of a kind. 4 of a kind. 5 of a kind. Yahtzee. and full house on a different java class.
    ************************************************** ************/
    public class Dice
    {
    Die [] dice;
    Random gen;

    /************************************************** ************
    The constructor uses a random generator to build each die.
    The number of Die objects is passed as a parameter.
    @param gen The random generator
    @param num The number of die objects
    ************************************************** ************/
    public Dice(Random gen, int num)
    {
    this.gen = gen;

    dice = new Die[num];
    for (int ii = 0; ii < dice.length; ii++)
    {
    dice[ii] = new Die(gen);
    }
    }
    /************************************************** ************
    This copy constructor returns an identical set of dice to
    the parameter. This is used to create a set of dice whose
    order can be changed from the original.You should use the
    Die constructor that creates a die with the same face value
    as the original for each of the Die in the set.

    @param dice The Dice object to copy
    ************************************************** ************/
    public Dice(Dice dice)
    {

    for(int ii = 0; ii < dice.getSize(); ii++)
    {
    this.dice[ii] = new Die(new Random());
    }
    // check me
    }
    Does this code compile?
    If yes, what are the exceptions thrown by JVM?
    If no, what are the errors spit out by compiler?

    And Welcome to Java Programming Forums. Read the forums Rules too. Enclose your code in code tags.

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need some assistance please

    The code does compile with no exceptions.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Need some assistance please

    Quote Originally Posted by JavaPhish View Post
    The code does compile with no exceptions.
    I'm not really sure what your question is then? If you want help, you'll have to ask a specific technical question and provide an SSCCE that demonstrates what's going on.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. New to the complmunity, need some assistance please.
    By nakedtriple in forum What's Wrong With My Code?
    Replies: 12
    Last Post: October 7th, 2011, 06:14 AM
  2. AI Search Simulator Assistance
    By GeekWarth in forum What's Wrong With My Code?
    Replies: 12
    Last Post: September 17th, 2011, 03:40 PM
  3. NEED ASSISTANCE W/ JAVA PROGRAM
    By Neddrick in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 29th, 2010, 08:20 PM
  4. array program assistance needed
    By JavaNoob82 in forum Collections and Generics
    Replies: 4
    Last Post: December 14th, 2009, 05:49 AM
  5. FileReader need assistance
    By tazjaime in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: November 8th, 2009, 01:12 AM