I’m in AP Comp Sci A, and we are doing a case study called “Grid World”. Basically there are bugs and rocks that move (or don’t) on a Grid. Each of these “Actors” has a “Location” which is their (row, column) cords as well as their direction. The person who programmed “Grid World” made its so you can add locations togethe4.
If and “Actor” was facing up this would cause it to face to the right:
new Location l = myLocation + Location.HALF_RIGHT;
How can I do this to other objects?
That’s an int.
That’s an int. You can’t add + and – functionality to your objects, but you could add a “add” and “subtract” method.
Also, your code won’t even compile. I think you mean:
Or, if your result location is an int: