Skip to main content
added clarification
Source Link
Korey Hinton
  • 2.7k
  • 3
  • 21
  • 30

I decided to stick with the statestate* pattern I had already implemented and I came up with a pretty simple solution that didn't involve a lot of code restructuring. I added an OPTIONAL state to the STATES enum and gave the StateConscious an optionalFlag boolean. For the StateConscious.next() and StateConscious.previous() methods I would give the proper next or previous state based on whether optionalFlag was set.

There were additional code changes to support the additional menu prompt but it was easily added.

Thanks to Amy Blankenship, pdr, and Steve Evers for their insight!

*Clarification: After posting question I realized I'm using State pattern not Memento pattern

I decided to stick with the state pattern I had already implemented and I came up with a pretty simple solution that didn't involve a lot of code restructuring. I added an OPTIONAL state to the STATES enum and gave the StateConscious an optionalFlag boolean. For the StateConscious.next() and StateConscious.previous() methods I would give the proper next or previous state based on whether optionalFlag was set.

There were additional code changes to support the additional menu prompt but it was easily added.

Thanks to Amy Blankenship, pdr, and Steve Evers for their insight!

I decided to stick with the state* pattern I had already implemented and I came up with a pretty simple solution that didn't involve a lot of code restructuring. I added an OPTIONAL state to the STATES enum and gave the StateConscious an optionalFlag boolean. For the StateConscious.next() and StateConscious.previous() methods I would give the proper next or previous state based on whether optionalFlag was set.

There were additional code changes to support the additional menu prompt but it was easily added.

Thanks to Amy Blankenship, pdr, and Steve Evers for their insight!

*Clarification: After posting question I realized I'm using State pattern not Memento pattern

Source Link
Korey Hinton
  • 2.7k
  • 3
  • 21
  • 30

I decided to stick with the state pattern I had already implemented and I came up with a pretty simple solution that didn't involve a lot of code restructuring. I added an OPTIONAL state to the STATES enum and gave the StateConscious an optionalFlag boolean. For the StateConscious.next() and StateConscious.previous() methods I would give the proper next or previous state based on whether optionalFlag was set.

There were additional code changes to support the additional menu prompt but it was easily added.

Thanks to Amy Blankenship, pdr, and Steve Evers for their insight!