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: arrays of card objects

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question arrays of card objects

    pls can any one explain the code below ;


    for (int count=0;count<deck.length;count++)
    deck[count]=new Card(faces[count%13],suits[count/13]);


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: arrays of card objects

    The loop is filling an array with new Card objects.
    Break the complicated statement inside the for loop into separate simple statements.
    What does the % operator do? Add a println to print out the results of count %13 and the results of count/13. The output will show you what the code is doing.

    What are the contents of the two arrays: faces and suits? How many elements would each array have?
    What would be used to create a new Card object?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 0
    Last Post: May 10th, 2012, 07:59 PM
  2. Random suit and card with arrays
    By SilentNite17 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 1st, 2012, 10:28 AM
  3. Problem with arrays and custom objects
    By MonkeyBeast in forum Collections and Generics
    Replies: 1
    Last Post: January 31st, 2012, 01:50 PM
  4. Arrays Of Objects?
    By MysticDeath in forum Object Oriented Programming
    Replies: 2
    Last Post: October 20th, 2009, 09:39 PM
  5. Throwing arrays as objects
    By Audemars in forum Collections and Generics
    Replies: 1
    Last Post: September 23rd, 2009, 06:29 PM