Wednesday, October 28, 2009

I really thought he'd give up and blame the tools.

Huzzah! I may not know the why but I know the how. So I needed to instantiate the variable point1 as a constructor value new point. Then, I needed to assign values to the point1.x and point1.y values. Ah, ha. They mean it when they say Java is strongly typed. Now in finishing the exercise which requires I set one of the three points equal to the other, I see reciprocity in the assignments as the second point to the equality reassigned affects the assignment of the first. Here is the output:

Start point is [10,10]
End point is [20,30]
Stray point is [20,30]
End point is [20,30]
Stray point is [47,50]
End point is [47,50]
Start point is [10,10]

What happened was we set stray = end. We then reassigned stray and the new values went into end. Neat trick or frustrating caveat? Only time will tell.

No comments:

Post a Comment