Java Reference
In-Depth Information
SOLUTION 24.3
The testSleep() method passes the doze command to the time() utility method of
the CommandUtil class:
public void testSleep() {
Command doze = new Command()
{
public void execute()
{
try
{
Thread.sleep(2000);
}
catch (InterruptedException ignore)
{
}
}
};
long t = CommandUtil.time(doze);
assertEquals(2000, t, 50);
}
SOLUTION 24.4
You can create the hook you need as an anonymous subclass:
package com.oozinoz.aster.client;
import com.oozinoz.aster.*;
public class ShowHook
{
public static void main(String[] args)
{
AsterStarPress2 p = new AsterStarPress2();
Hook h = new Hook()
{
public void execute(AsterStarPress2 p)
{
MaterialManager m =
MaterialManager.getManager();
m.setMoldIncomplete(p.getCurrentMoldID());
}
};
p.setMarkMoldIncompleteHook(h);
}
}
SOLUTION 24.5
In F ACTORY M ETHOD , a client knows when to create a new object but doesn't know what
kind of object to create. F ACTORY M ETHOD moves object creation to a method that isolates
a client from knowing which class to instantiate. This principle also occurs in A BSTRACT
F ACTORY .
Search WWH ::




Custom Search