T
Terry Holland
I am writing a Sudoku Solver application as an excersise for learning about
some VB.Net objects and it has thrown up a few questions
The model I am using for my business objects is as follows:
I have the following classes:
Grid
Cell
Row
Column
Block
Ive also got a Range class from which Row, Column & Block are derived.
The Grid contains 81 cells labelled 1-81
The grid also contains
9 Row objects, each of which contain 9 Cell objects
9 Column objects, each of which contain 9 Cell objects
9 Block objects, each of which contain 9 Cell objects
Each cell is contained by 1 Row, 1 Column & 1 Block (as well as the Grid)
When a value changes in a Cell, this has an impact on the other cells in the
Row, Column and Block that contains this Cell
Im having difficulty understanding how to do the following:
When a value in a cell changes, how do I inform other related objects
ie Cell 1 is in Row 1, Column 1 & Block 1. If Cell 1 is set to value 6 then
every other Cell in Row 1, Column 1 & Block 1 needs to know about this.
I have been trying to model this by having a Range class as follows
Public Class Range
Inherits Collections.Generic.List(Of Cell)
...
End Class
Public Class Cell
...
End Class
and Row, Column and Block classes as follows:
Public Class Row
Inherits Range
...
End Class
Public Class Column
Inherits Range
...
End Class
Public Class Block
Inherits Range
...
End Class
I was hoping that I could have an event in my Cell class that i could raise
whenever a Cell value changed, and then respond to that event in the Range
class and make necessary modifications to all other Cell objects contained in
the Range but I dont see any mechanism for detecting an event in a Cell class
from the Range class.
Any suggestions?
Sorry I dont have any real code but this is a bit conceptual at the moment &
I dont have Visual Studio on this machine :-(
some VB.Net objects and it has thrown up a few questions
The model I am using for my business objects is as follows:
I have the following classes:
Grid
Cell
Row
Column
Block
Ive also got a Range class from which Row, Column & Block are derived.
The Grid contains 81 cells labelled 1-81
The grid also contains
9 Row objects, each of which contain 9 Cell objects
9 Column objects, each of which contain 9 Cell objects
9 Block objects, each of which contain 9 Cell objects
Each cell is contained by 1 Row, 1 Column & 1 Block (as well as the Grid)
When a value changes in a Cell, this has an impact on the other cells in the
Row, Column and Block that contains this Cell
Im having difficulty understanding how to do the following:
When a value in a cell changes, how do I inform other related objects
ie Cell 1 is in Row 1, Column 1 & Block 1. If Cell 1 is set to value 6 then
every other Cell in Row 1, Column 1 & Block 1 needs to know about this.
I have been trying to model this by having a Range class as follows
Public Class Range
Inherits Collections.Generic.List(Of Cell)
...
End Class
Public Class Cell
...
End Class
and Row, Column and Block classes as follows:
Public Class Row
Inherits Range
...
End Class
Public Class Column
Inherits Range
...
End Class
Public Class Block
Inherits Range
...
End Class
I was hoping that I could have an event in my Cell class that i could raise
whenever a Cell value changed, and then respond to that event in the Range
class and make necessary modifications to all other Cell objects contained in
the Range but I dont see any mechanism for detecting an event in a Cell class
from the Range class.
Any suggestions?
Sorry I dont have any real code but this is a bit conceptual at the moment &
I dont have Visual Studio on this machine :-(