Design Patterns Java™ Workbook
Chapter 20. Introducing Operations METHOD pattern allows subclasses to implement methods that adjust the effect of a procedure d ...
Chapter 21. Template Method..................................................................................................... ...
Chapter 21. Template Method Figure 21.1. The sort() method can sort any list, using a method that you supply to perform the comp ...
Chapter 21. Template Method Rocket r2 = new Rocket( "Pocket", 2.95, (Length) METER.times(12)); Rocket r3 = new Rocket( "Sock-it" ...
Chapter 21. Template Method not shown in the diagram, that dispense the chemicals that the machine mixes into a paste and presse ...
Chapter 21. Template Method Figure 21.3. Star presses from Aster Corporation come with an abstract class that you must subclass ...
Chapter 21. Template Method CHALLENGE 21.2 Write the code for the markMoldIncomplete() method of OzAsterStarPress. package com.o ...
Chapter 21. Template Method public void dischargePaste() { super.dischargePaste(); getFactory().collectPaste(this); } This metho ...
Chapter 21. Template Method Figure 21.4. A Machine object can create an appropriate MachinePlanner instance for itself. Suppose ...
Chapter 21. Template Method CHALLENGE 21.4 Suppose that you provide the Machine class with a planner attribute of type MachinePl ...
Chapter 22. State............................................................................................................... ...
Chapter 22. State Figure 22.1. A carousel door provides one-touch control with a single button that changes the door's state. Th ...
Chapter 22. State Figure 22.2. The Door_1 class models a carousel door, relying on state change events sent by the carousel mach ...
Chapter 22. State case STAYOPEN : return "StayOpen"; default : return "Closed"; } } When a user clicks the carousel's one-touch ...
Chapter 22. State Figure 22.3. This diagram shows a door's states as classes in an arrangement that mirrors the door's state mac ...
Chapter 22. State public final DoorState OPEN = new DoorOpen(this); public final DoorState CLOSING = new DoorClosing(this); publ ...
Chapter 22. State package com.oozinoz.carousel; public class Door_2 extends Observable { // ... (DoorState variables) public voi ...
Chapter 22. State public void click() { door.setState(door.STAYOPEN); } public void timeout() { door.setState(door.CLOSING); } } ...
Chapter 22. State CHALLENGE 22.5 Complete the class diagram in Figure 22.4 to show a design that moves the door states to an int ...
Chapter 23. Strategy............................................................................................................ ...
«
5
6
7
8
9
10
11
12
13
14
»
Free download pdf