[Cs3] State lab

Mikhail Nesterenko mikhail at cs.kent.edu
Thu Dec 6 15:23:24 EST 2018


> 
> In our process class, are we suppose to maintain 3 private member variables
> such as: State* currentState, static int process_count, and int ID? Would
> this be suffice or am I doing it completely wrong?

process is free to maintain non-changing information, such as its id
(btw, consider making it const and initializing it using constructor
initializer list) as a private variable. 

Same applies to the static process count variable.

It is its changing state that needs to be implemented as State Design Pattern.

> 
> Is the constructor of the process class suppose to increment the
> process_count, reassign the ID, 

yes

> and change the currentState variable as
> well?

and, as a part of the implementation of the State Design Pattern,
point the state variable to the initial state class.

> 
> For our State class, would it be ideal to not provide a constructor but
> rather have the derived classes of the State class maintain an instance
> function that creates a new state just the zork example that you provided?

probably

> If that is the case, how is the Prototype design pattern suppose to be
> incorporated into the lab? I know that the prototype class has a clone
> function that creates a prototype but I do not understand how the prototype
> design pattern is supposed to be implemented in this lab.

create a (prototype) process in the initial state and then clone the
four required processes from this prototype.

thanks,
--
Mikhail


More information about the cs3 mailing list