March 2002
Intermediate to advanced
496 pages
8h 51m
English
| SOLUTION 28.1 | A working program is:
package com.oozinoz.applications;
import com.oozinoz.fireworks.*;
public class ShowFireworkList
{
public static void main(String[] args)
{
FireworkList flist =
Promo.getPromotionalFireworks();
FireworkList.Itr i = flist.iterator();
while (i.hasNext())
{
Firework f = i.next();
System.out.println(
f.getName()
+ ", $" + f.getPrice()
+ ", " + f.getType());
}
}
}
|
| SOLUTION 28.2 | As Chapter 16, Factory Method, describes, iterators provide a classic example of the FACTORY METHOD pattern. A client that wants an iterator for an instance of a ProcessComponent knows when to create the iterator, but the receiving class knows which class to instantiate. |
| SOLUTION 28.3 | You need to change the next() code ... |
Read now
Unlock full access