Java Reference
In-Depth Information
60. }
61. }
62. }
The RunPattern class creates the InternationalizationWizard and associates it with the GUI; subsequently,
the InternationalizationWizard (Facade) can be used to obtain information about the currently selected
country.
Example A.170 RunPattern.java
1. import java.io.File;
2. public class RunPattern{
3. public static void main(String [] arguments){
4. System.out.println("Example for the Facade pattern");
5. System.out.println();
6. System.out.println("This code sample uses an InternationalizatgionWizard (a
Facade)");
7. System.out.println(" to manage communication between the rest of the application
and");
8. System.out.println(" a series of other classes.");
9. System.out.println();
10. System.out.println("The InternationalizatgionWizard maintains a colleciton of
Nation");
11. System.out.println(" objects. When the setNation method is called, the wizard sets
the");
12. System.out.println(" default nation, updating the Currency, PhoneNumber and
localized");
13. System.out.println(" String resources (InternationalizedText) available.");
14. System.out.println();
15. System.out.println("Calls to get Strings for the GUI, the currency symbol or the
dialing");
16. System.out.println(" prefix are routed through the Facade, the
InternationalizationWizard.");
17. System.out.println();
18.
19. if (!(new File("data.ser").exists())){
20. DataCreator.serialize("data.ser");
21. }
22.
23. System.out.println("Creating the InternationalizationWizard and setting the nation
to US.");
24. System.out.println();
25. InternationalizationWizard wizard = new InternationalizationWizard();
26. wizard.setNation("US");
27.
28. System.out.println("Creating the FacadeGui.");
29. System.out.println();
30. FacadeGui application = new FacadeGui(wizard);
31. application.createGui();
32. application.setNation(wizard.getNation("US"));
33. }
34. }
 
Search WWH ::




Custom Search