Java Reference
In-Depth Information
Strategy (Chapter 23)
SOLUTION 23.1
The GroupAdvisor and ItemAdvisor classes are instances of A DAPTER , 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() {}
Search WWH ::




Custom Search