Imagine the following situation: You have a chess board with four squares and from 0 to 12 sticks - like wooden matches or toothpicks. You can place one match along the edge of any square or between any two squares:
_ _
|_|_|
|_|_|
When you have a match on the board, you can move it by rotating it 90 degrees from either end, providing the spot you are rotating it into is open.
One other wrinkle: when you create the board, you do so with a specified number of sticks. For instance, you might start with four sticks. You could add up to four sticks to the board and move them any way you wanted to and remove them, but you could never add a fifth stick.
Oh, what's this for?
Well, I've been playing with some C# in the last few days. I spent a lot of time learning C and even some assembly language. That was a lot of fun, but it meant I neglected the things that object oriented languages are good at and useful for: object design.
I realized this, anew, over the last couple of days, when I tried to implement the exercise above. Once I got to some still simple behaviors using my basic design, it got harder and harder to get the program to do what I had set out for it to do.
Since I'm going to spend time on this problem, anyway, I may as well blog it.
This time, I won't have a specific time limit, as I did with the assembly blog.
Oh, and one other thing: I intend to write tests at the same time I write the code. I made a stab at this, as I got started.
I'm working in the PowerShell IDE, not Visual Studio. Maybe I'll explain why tomorrow.
No comments:
Post a Comment