I am generating a sequence of Step
objects that differ by "Type" and data contained within. e.g:
The Step
objects should basically be structs that look like this
{ GRAB, CASCADE_ONE, FACEUP, SOMEOTHERDATA },
{ DROP, DECK, FACEDOWN, MOREDATA, ANDSOMEMORE },
{ MOVE, 34, 89 },
where GRAB
, MOVE
and DROP
indicate StepType
:
typedef enum
{
GRAB,
DROP,
MOVE
}StepType;
As you can see, depending on StepType
, these structs each have variable numbers of data fields after the StepType
.
I plan to iterate over a sequence of these structs and perform a particular action based on the StepType
field. My first hunch is that these should be objects of classes derived from an abstract Step
class - i.e. I should create a GrabStep
class, a MoveStep
class and a DropStep
class.
Is this a good design and if so should I create them using a factory method? If a factory method is the way to go, then how to initialise the fields within the objects?