Brainstorm with me on this

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 ;)
 
A

Alex Papadimoulis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top