I am writing a program where I have a 2D array of objects from a cell class, and I need to write a method where I pass a cell object as a parameter and I return an arraylist of cells that surround the cell(N, S, E, W). Each cell is given a location from the Point class. What I am having trouble with is how to use the locations that I know(x, y-1 is north) to produce a cell. Any help on this is appreciated. Thank you.
Share
If (x,y) is your cell then the four surrounding cells to it is
and you might make assumptions that
so
to the cell you pass as paremeter to your method.