I am designing a C++ console program that models a board of Shapes. The only rule is that all Shapes that are placed on the board have to be added to an existing Line (with the exception of the first move). Whenever a Shape is placed on the board, it has a Line in both the horizontal and vertical direction, even if it is the only member of the line.
I have implemented the Line and Shape objects fine. The issue I am struggling with is how to organize the lines. It didn’t seem like a good idea to give the line a position (as in a x,y coordinate), because the board is dynamic and can expand in any direction. Right now each line only has a direction, vertical or horizontal. I also need to be able to print the board to the console, so the user can indicate where they want to add on.
Does anyone have any ideas for how to model this situation efficiently?
It’s not completely clear what the rules are, but if you’re concerned about a freely expanding grid, you could consider storing the
Shapeobjects in a map:Perhaps you could elaborate more on the gameplay.