Results 1 to 4 of 4
  1. #1
    BinaryVeil is offline Member
    Join Date
    Dec 2014
    Posts
    2
    Rep Power
    0

    Default Having problems with 2D-dimensional arrays of object types.

    Hello,
    I need to write a class that represents and image of RGB pixels. This class uses a two-dimensional array of object type that represents R,G and B values.
    When I compile the class it completes successfully. However, when I try running a "tester" class , I'm encountering errors in a few methods. I've been trying it out for 2 days now, but unsuccessfully thus far..
    Those method are : rotating the image by 90 degrees clockwise (and vice versa , but I just use clockwise method 3 times for that) , shifting the image sideways, and shifting the image up/down..

    I've attached the whole source code for the class , and the list of errors I get when I try to run my tester.

    https://gist.github.com/anonymous/6c...-gistfile1-txt




    Thanks!
    Last edited by BinaryVeil; 12-08-2014 at 08:15 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Having problems with 2D-dimensional arrays of object types.

    The image takes ages to load for me; please copy (some of) the relevant errors and the relevant part of your source code.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    BinaryVeil is offline Member
    Join Date
    Dec 2014
    Posts
    2
    Rep Power
    0

    Default Re: Having problems with 2D-dimensional arrays of object types.

    here's the code with the more relevant parts:
    https://gist.github.com/anonymous/f2...-gistfile1-txt

    It mostly shows ArrayIndexOutOfBoundsException
    Last edited by BinaryVeil; 12-08-2014 at 08:40 PM.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Having problems with 2D-dimensional arrays of object types.

    You need to use print statements in your shift methods to see the values of offset and how it is affecting the computation. You also need to check your invariants of your setPixel and getPixel methods. Using <= would allow out of bounds row or column selection.

    In general, if you don't know why something isn't working, sprinkle some print statements in your program to check state.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 4
    Last Post: 06-28-2014, 05:00 PM
  2. Two dimensional arrays
    By mackenzie1235 in forum New To Java
    Replies: 12
    Last Post: 12-16-2013, 04:40 PM
  3. two dimensional arrays
    By cliffh in forum New To Java
    Replies: 2
    Last Post: 11-05-2010, 11:43 PM
  4. dynamic two dimensional arrays?
    By dinosoep in forum New To Java
    Replies: 4
    Last Post: 12-05-2009, 06:12 PM
  5. Multi-dimensional array with different types in it.
    By vilislacis in forum New To Java
    Replies: 2
    Last Post: 09-19-2009, 10:46 PM

Posting Permissions

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