Java Reference
In-Depth Information
12. System.out.println();
13. System.out.println("The OrderedListImpl class provides the underlying storage");
14. System.out.println(" capability for the list, and can be flexibly paired with");
15. System.out.println(" either of the classes which provide the abstraction.");
16.
17. System.out.println("Creating the OrderedListImpl object.");
18. ListImpl implementation = new OrderedListImpl();
19.
20. System.out.println("Creating the BaseList object.");
21. BaseList listOne = new BaseList();
22. listOne.setImplementor(implementation);
23. System.out.println();
24.
25. System.out.println("Adding elements to the list.");
26. listOne.add("One");
27. listOne.add("Two");
28. listOne.add("Three");
29. listOne.add("Four");
30. System.out.println();
31.
32. System.out.println("Creating an OrnamentedList object.");
33. OrnamentedList listTwo = new OrnamentedList();
34. listTwo.setImplementor(implementation);
35. listTwo.setItemType('+');
36. System.out.println();
37.
38. System.out.println("Creating an NumberedList object.");
39. NumberedList listThree = new NumberedList();
40. listThree.setImplementor(implementation);
41. System.out.println();
42.
43. System.out.println("Printing out first list (BaseList)");
44. for (int i = 0; i < listOne.count(); i++){
45. System.out.println("\t" + listOne.get(i));
46. }
47. System.out.println();
48.
49. System.out.println("Printing out second list (OrnamentedList)");
50. for (int i = 0; i < listTwo.count(); i++){
51. System.out.println("\t" + listTwo.get(i));
52. }
53. System.out.println();
54.
55. System.out.println("Printing our third list (NumberedList)");
56. for (int i = 0; i < listThree.count(); i++){
57. System.out.println("\t" + listThree.get(i));
58. }
59. }
60. }
 
Search WWH ::




Custom Search