Java Reference
In-Depth Information
82. public static ArrayList createAttendees(int numberToCreate){
83. ArrayList group = new ArrayList();
84. for (int i = 0; i < numberToCreate; i++){
85. group.add(new ContactImpl("John", getLastName(i), "Employee (nonexempt)", "Yoyodyne
Corporation"));
86. }
87. return group;
88. }
89.
90. public static String getLastName(int index){
91. String name = "";
92. switch (index % 6){
93. case 0: name = "Worfin";
94. break;
95. case 1: name = "Smallberries";
96. break;
97. case 2: name = "Bigbootee";
98. break;
99. case 3: name = "Haugland";
100. break;
101. case 4: name = "Maassen";
102. break;
103. case 5: name = "Sterling";
104. break;
105. }
106. return name;
107. }
108.
109. public static void printExceptions(InformationRequiredException exc){
110. int statusCode = exc.getInformationRequired();
111.
112. System.out.println("Unable to create Appointment: additional information is
required");
113. if ((statusCode & InformationRequiredException.START_DATE_REQUIRED) > 0){
114. System.out.println(" A start date is required for this appointment to be
complete.");
115. }
116. if ((statusCode & InformationRequiredException.END_DATE_REQUIRED) > 0){
117. System.out.println(" An end date is required for this appointment to be
complete.");
118. }
119. if ((statusCode & InformationRequiredException.DESCRIPTION_REQUIRED) > 0){
120. System.out.println(" A description is required for this appointment to be
complete.");
121. }
122. if ((statusCode & InformationRequiredException.ATTENDEE_REQUIRED) > 0){
123. System.out.println(" At least one attendee is required for this appointment to
be complete.");
124. }
125. if ((statusCode & InformationRequiredException.LOCATION_REQUIRED) > 0){
126. System.out.println(" A location is required for this appointment to be
complete.");
127. }
128. System.out.println();
129. }
130. }
 
Search WWH ::




Custom Search