我想創建一個組件,它由一個電路板及其周圍的角組成。在運行時定義板的尺寸(因此也是邊界)。一些示例(電路板明亮,邊框暗): alt text http://img340.imageshack.us/img340/3862/examplegw.png在我的示例中使用什麼數據結構
電路板由BoardCell類型的對象組成,邊框由BorderCell類型的對象組成。 Board的數據結構是BoardCell [,] - 一個簡單的二維數組。
如何表示邊界?我開始這樣的事情:
public BorderCell TopLeft // top left corner cell
public BorderCell TopRight // top right corner cell
public BorderCell BottomRight // bottom right corner cell
public BorderCell BottomLeft // bottom left corner cell
public BorderCell[] Top // top border (without corners)
public BorderCell[] Bottom // bottom border (without corners)
public BorderCell[] Left // left border (without corners)
public BorderCell[] Right // right border (without corners)
我不喜歡這種邊界的表示,你能提出更好的建議嗎?
附加:我想有一個方法SetSomethingForTheCell邊界對象:
public void SetSomethingForTheCell(...)
,但我目前的數據結構,我不知道該怎麼作爲參數傳遞。
這取決於你想用電池做什麼。 – SLaks 2010-06-29 11:52:48
你是否曾經必須遍歷所有的細胞獨立,如果他們是邊界或板細胞?你(如何)解決他們? – 2010-06-29 11:53:35
SLaks:BoardCell僅包含數據且不包含任何行爲。 BorderCell主要包含行爲和一些數據,與BoardCell完全不同。 – sventevit 2010-06-29 11:57:06