This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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
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.
Joined: Feb 05, 2005
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?