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.

Page 3 of 3 FirstFirst 123
Results 51 to 61 of 61

Thread: Making a method to move blocks in a grid

  1. #51
    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: Making a method to move blocks in a grid

    That is wrong. What are those single letter variables?
    If you don't understand my answer, don't ignore it, ask a question.

  2. #52
    Member
    Join Date
    May 2012
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Making a method to move blocks in a grid

    Quote Originally Posted by geforce View Post
    for every row equal to 0 to BLOCKROWS
    for every column equal to 0 to NBLOCKS
    create x and y to compute location
    create colour
    perform addbrick
    create row
    create column
    perform i * j
    add (i * j) to list
    return the list
    Do you mean the variables in i and j?

    if so i is the row and j is the column ohhh, so

    create row
    create column
    Last edited by geforce; May 21st, 2012 at 08:32 PM.

  3. #53
    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: Making a method to move blocks in a grid

    create x and get y to compute location ????

    create i
    create j
    perform i * j
    add (i * j) to list

    None of the above makes any sense to me. If i and j are the loop variables, what does "create" mean?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #54
    Member
    Join Date
    May 2012
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Making a method to move blocks in a grid

    for every row equal to 0 to BLOCKROWS
    for every column equal to 0 to NBLOCKS
    create x
    create y
    create colour
    perform addbrick (list created)
    perform row * ROWSEPARATION + ROWZERO
    perform column * BLOCKWIDTH
    (add row and column) add to list location
    return list

  5. #55
    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: Making a method to move blocks in a grid

    create x
    You would compute the value of x outside the inner loop because it would apply to all the shapes being created in the inner loop.

    perform row * ROWSEPARATION + ROWZERO
    perform column * BLOCKWIDTH
    (add row and column) add to list location
    These make no sense to me. Can you explain what each of them means?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #56
    Member
    Join Date
    May 2012
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Making a method to move blocks in a grid

    Is Y also computed outside the loop?

    It says that:
    The i'th row of blocks has its upper edge aligned with i (row) * ROWSEPARATION +ROWZERO.

    The j'th column of blocks has its left edge aligned with j (column) * BLOCKWIDTH

    since the column depends on the row , row + column would be the answer
    Last edited by geforce; May 21st, 2012 at 08:47 PM.

  7. #57
    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: Making a method to move blocks in a grid

    Is Y also computed outside the loop?
    How can it? It is where the shapes go on the current row.

    Look at the drawing you made of the grid you are building. See how the values of the locations where each shape goes relates to the row and column and how the values of the uppercase constant variables determine where the next shape goes.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #58
    Member
    Join Date
    May 2012
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Making a method to move blocks in a grid

    When row is at 0 the row goes to 50
    When column is at 0 the column goes to 0

    When row is at 1 the row goes to 100
    When the column is at 1 the column goes to 50

    The row is always ahead of the column by 50 atleast so no errors would occur

  9. #59
    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: Making a method to move blocks in a grid

    None of those last two posts makes any sense to me.

    That's it for tonight. Back tomorrow.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #60
    Member
    Join Date
    May 2012
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Making a method to move blocks in a grid

    sigh... -.-

  11. #61
    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: Making a method to move blocks in a grid

    Any luck on getting a design for your project?
    If you don't understand my answer, don't ignore it, ask a question.

Page 3 of 3 FirstFirst 123

Similar Threads

  1. BufferedReader.read() blocks,when checking if there's any input for some URLs
    By redateksystem in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: March 27th, 2012, 09:33 AM
  2. Need help making an image move from one side of screen to the other.
    By Xillius200 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 25th, 2011, 12:46 PM
  3. [SOLVED] Things Won't Move
    By zeraxis in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 2nd, 2011, 08:46 AM
  4. Grid bag layout inside grid bag layout
    By kiddkoder in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 29th, 2011, 08:07 AM
  5. Nested try blocks
    By Ahmed. in forum Member Introductions
    Replies: 2
    Last Post: April 30th, 2010, 08:12 AM