aspose file tools*
The moose likes Beginning Java and the fly likes Array Testing Output Confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array Testing Output Confusion" Watch "Array Testing Output Confusion" New topic
Author

Array Testing Output Confusion

Greg Roberts
Ranch Hand

Joined: Feb 05, 2005
Posts: 72
This is for an Intermediate Java class I'm taking this semester. I'm having a problem with testing for out of bounds in an array in my class.

Here is the code that's in the driver program:


And here is the code for the addLine method:


This is the output it produces:
Out of bounds error or start and end points are the same.
Out of bounds error or start and end points are the same.
Out of bounds error or start and end points are the same.
Out of bounds error or start and end points are the same.


Can anyone tell me why it is producing 4 outputs when only three sets of numbers are put through the test? The method tests whether the supplied numbers are not out of bounds of the 2D array, and whether the start and end points do not equal each other. The point of the driver code here is to make sure the driver rejects the numbers.

Also, I'm not sure if my code is correct to draw a straight line in an array of bytes. 0 is a black pixel, 1 is a white pixel. So I have a 2D array of bytes (pixels).

Thanks for any help on this!


Greg Roberts<br />CIS Student<br />University of West Florida
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1821

I can't tell from the code you've posted; try adding the following line at the start of your method:



This will tell you the parameters that it's working with.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Greg Roberts
Ranch Hand

Joined: Feb 05, 2005
Posts: 72
Actually, that helped me figure out why its printing 4 lines. See the driver program goes through all these tests with the class (the driver is provided, we have to write the class) and it was moving onto the next test without me realizing it. I'm always forgetting to add stuff like the line you provided when debugging. Thanks!

Any advice on the code for drawing the line in the array?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array Testing Output Confusion