Design Patterns Java™ Workbook

(Michael S) #1
Appendix B. Solutions

public void complete()
{
door.setState(door.CLOSED);
}
}


SOLUTION 22.5....................................................................................................................................


Figure B.25 shows a reasonable diagram. The code for this refactoring is in
the com.oozinoz.carousel_sol package.


Figure B.25. This diagram shows the Door and DoorState classes sharing constants that
DoorConstants defines.

The code for DoorConstants is:

Free download pdf