Background
I'm looking for hints / pointers on how to approach this. When I search for table or grid, I get the UI stuff which is not what I'm looking for.
I don't know if this sounds like homework, but it is not. This is for a map of crops and I need to determine the crops planted around a particular plot of land.
Problem
I have a table of information, its 6 rows by 6 columns, but it can be any size.
I need to find a box in that table, and then get the information from all of the boxes around it.
|-1-|-2-|-3-|-4-|-5-|-6-|
|-7-|-8-|-9-|-A-|-B-|-C-|
|-D-|-E-|-F-|-G-|-H-|-I-|
|-J-|-K-|-L-|-M-|-N-|-O-|
|-P-|-Q-|-R-|-S-|-T-|-U-|
|-V-|-W-|-X-|-Y-|-Z-|-0-|
So I need to be able to pick box M and get the information for F,G,H,N,T,S,R,L
Note, if box J was needed, it is okay to return blanks or nulls for the boxes on the left that doen't exist. It does not wrap around and get the boxes from the other side of the table.
My Idea
I guess I could start with an array of arrays.
private static string[][] tableData;
So when looking for box M, I would need to get the row (i) and column (j) index for M, then the surrounding cells are as "simple" as:
| i-1, j-1 | i-1, j | i-1, j+1 |
| i, j-1 | i, j | i, j+1 |
| i+1, j-1 | i+1, j | i+1, j+1 |
And when asked for box M, I could find box M's index, then get the prior "row" and then index -1, index, and index + 1. Do that for M's row -1, M's row and then M's row + 1.
Is that a fair and good way of doing this or are there better, perhaps already built classes that I should use?
So the question: is an array of arrays the best way to handle this problem, or is there a better way?