Brainstorm with me on this

  • Thread starter Thread starter George Durzi
  • Start date Start date
G

George Durzi

Hey all. I need your help in designing a solution. I'm building a small wine
cellar manager application as a side project. A wine cellar can consist of
several "walls", each of which can have X rows and Y columns.

I'm trying to figure out a way to illustrate how certain walls in a cellar
are positioned with respect to each other. Consider a simple wine cellar
with walls called: Top, Left, Middle and Right.

If I were to draw this in HTML, it would be something like this:

<table>
<tr>
<td colspan="3">Top</td>
</tr>
<tr>
<td>Left</td>
<td>Middle</td>
<td>Right</td>
</tr>
</table>

"Top" is ABOVE "Left"
"Top" is ABOVE "Middle"
"Top" is ABOVE "Right"

"Left" is UNDER "Top"
"Middle" is UNDER "Top"
"Right" is UNDER "Top"

"Left" is LEFT of "Middle"
Nothing is LEFT of "Left"
"Right" is RIGHT of "Middle"
Nothing is RIGHT of "Right"

Obviously the friendly names Top, Left, Middle, and Right are arbitrary ...

What would be a good way to capture this? Can anyone suggest a suitable data
structure?

I know this is somewhat off topic, but the front end of this is all aspx, so
it's a little relevant ;)
 
Hi George,

I see two strong ways of approaching this.

If the walls can be represented pretty much in a HTML table, simply
represent a table-like structure. The Cellar would have a BlocksHigh and
BlocksWide property. It would contain a collection of Walls, which would
each contain an array of Cell numbers they occupy. In your example,
BlocksHigh=2 and BlocksWide=3. Walls would consists of Top (1,2,3), Left
(4), Middle (5), Right(6), with the CellNumbers array parenthesis.

On the other hand, if the walls really cant be represented in a grid like
that, then you'll have to do a four-sided linked list type structure. The
Cellar would contain a NumberOfWalls property, and a TopLeftWall property,
which would contain in your example, the Top wall. The Wall structure would
contain four properties (each of type Wall), called Above, Below, LeftOf,
RightOf. Middle, in your example, would have Above="Top", Below=Null,
LeftOf="Left", RightOf="Right".

How's that work

Alex Papadimoulis
 
Back
Top