Listing 8: The ChargingDevices classa main method for informal testing
public class ChargeDevices
{
public static void main(String[] args)
{
System.out.println("-- Device Charging Application --");
System.out.println();
// create the chargers
Charger lighter = new CigaretteLighter("cigarette lighter");
Charger outlet = new WallOutlet("wall outlet");
// create the devices
Device gameBoy = new GameBoy();
Device cellPhone = new CellPhone();
// create the device adapters
Charger device01 = new DeviceAdapter(gameBoy);
Charger device02 = new DeviceAdapter(cellPhone);
String charger01 = lighter.getCharger();
String charger02 = outlet.getCharger();
// charge the devices
device01.chargeDevice(charger01);
device02.chargeDevice(charger01);
device01.chargeDevice(charger02);
}
}
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|