Strategy (Chapter 23)
SOLUTION 23.1 | The GroupAdvisor and ItemAdvisor classes are instances of ADAPTER, providing the interface a client expects, using the services of a class with a different interface. |
SOLUTION 23.2 | Figure B.26 shows one solution.
Figure B.26. The advertising policy at Oozinoz includes four strategies that appear as four implementations of the Advisor interface. |
SOLUTION 23.3 | The code for ItemAdvisor.java should look something like:
package com.oozinoz.recommend; import com.oozinoz.fireworks.*; public class ItemAdvisor implements Advisor { public static final ItemAdvisor singleton = new ItemAdvisor(); private ItemAdvisor() {} public ... |
Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.