Java Reference
In-Depth Information
plet
. And we'll initially take the easiest path from ingredients to cookies before we complic-
ate it.
Example 23-5. Cooklet.java
/** A simple class, just to provide the list of methods that
* users need to provide to be usable in our application.
* Note that the class is abstract so you must subclass it,
* but the methods are non-abstract so you don't have to provide
* dummy versions if you don't need a particular functionality.
*/
public
public abstract
abstract class
class
Cooklet
Cooklet
{
/** The initialization method. The Cookie application will
* call you here (AFTER calling your no-argument constructor)
* to allow you to initialize your code
*/
public
public
void
void
initialize
( ) {
}
/** The work method. The cookie application will call you
* here when it is time for you to start cooking.
*/
public
public
void
void
work
( ) {
}
/** The termination method. The cookie application will call you
* here when it is time for you to stop cooking and shut down
* in an orderly fashion.
*/
public
public
void
void
terminate
( ) {
}
}
Now, because we'll be baking, err, making this available to other people, we'll probably
want to cook up a demonstration version too; see
Example 23-6
.
Example 23-6. DemoCooklet.java
public
public class
class
DemoCooklet
DemoCooklet
extends
extends
Cooklet
{
public
public
void
void
work
() {
System
.
out
.
println
(
"I am busy baking cookies."
);
}
public
public
void
void
terminate
() {
System
.
out
.
println
(
"I am shutting down my ovens now."
);
}
}