Advertisement
Guest User

Untitled

a guest
Mar 26th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.32 KB | None | 0 0
  1. public class CallCentreTester
  2. {
  3. public static void main(String[] args)
  4. {
  5. System.out.print("Enter the maximum number of calls that can be taken in the centre: ");
  6.  
  7. //take in an int from the user for the maximum number of calls in the call centre
  8. int maxNumberOfCalls = EasyScanner.nextInt();
  9.  
  10. //initialise the call centre with the maximum number of calls entered by the user
  11. CallCentre callCentre = new CallCentre(maxNumberOfCalls);
  12.  
  13. char choice;
  14.  
  15. do
  16. {
  17. //Displays the menu
  18. System.out.println();
  19. System.out.println("Call Centre System");
  20. System.out.println();
  21. System.out.println("1: Add a Call");
  22. System.out.println("2: Remove a call");
  23. System.out.println("3: Update call Status");
  24. System.out.println("4: Check if the call list is Empty");
  25. System.out.println("5: Check if the call list is Full");
  26. System.out.println("6: Call details...");
  27. System.out.println("7: Update suggested length of call");
  28. System.out.println("8: Exit System");
  29. System.out.println();
  30.  
  31. //gets input from user
  32. System.out.print("Please Enter choice [1-8]: ");
  33. choice = EasyScanner.nextChar();
  34.  
  35. if(choice == 1) //add a call
  36. {
  37. option1(callCentre);
  38. }
  39. else if (choice == 2) // remove a call
  40. {
  41. option2(callCentre);
  42. }
  43. else if (choice == 3) // update call status
  44. {
  45. option3(callCentre);
  46. }
  47. else if (choice ==4) // check if the call list is empty
  48. {
  49. option4(callCentre);
  50. }
  51. else if (choice ==5) // Check if the call list is Full
  52. {
  53. option5(callCentre);
  54. }
  55. else if (choice ==6) // Call details...
  56. {
  57. option6(callCentre);
  58. }
  59. else if (choice ==7) // Update suggested length of call
  60. {
  61. option7(callCentre);
  62. }
  63. else if (choice ==8) // Exit System
  64. {
  65. System.out.println("Exiting the system");
  66. }
  67. else // if the user picks anything below 1 or above 8
  68. {
  69. System.out.println("That is not a valid option, please try again.");
  70. }
  71.  
  72. //if the user picks 8 then the do-while loop will exit
  73. } while (choice != 8);
  74.  
  75. }
  76.  
  77. private static void option1(CallCentre callCentre) //add a call
  78. {
  79. System.out.println("Add a Call: ");
  80.  
  81. System.out.println("\tEnter Call Id: ");
  82. String callId = EasyScanner.nextString(); // input call id
  83.  
  84. System.out.println("\tEnter length of the call (mininutes): ");
  85. int numMinutes = EasyScanner.nextInt(); // input num minutes
  86.  
  87. System.out.println("\tEnter call status(open, pending or closed): ");
  88. String callStatus = EasyScanner.nextString(); // input call status
  89.  
  90. System.out.print("\tDo you need to call the customer back (y/n): ");
  91. char choice = EasyScanner.nextChar(); // input char for callBackCustomer
  92.  
  93. boolean callBackCustomer = false;
  94. if (choice == 'y' || choice == 'Y') // if the user types a lower case or upper case y
  95. {
  96. callBackCustomer = true; // set to true
  97. }
  98. else if (choice == 'n' || choice == 'N') // if the user types a lower case or upper case n
  99. {
  100. callBackCustomer = false; // set to false
  101. }
  102.  
  103. System.out.println("\tEnter agent name");
  104. String callAnsweredBy = EasyScanner.nextString(); // input callAnsweredBy
  105.  
  106. System.out.println("How happy was your customer? 1 (very happy) to 5 (very unhappy): 3");
  107. int customerSatisfactionRating = EasyScanner.nextInt(); // input customerSatisfactionRating
  108.  
  109. //create a new call with the information input by the user
  110. Call call = new Call(callId, numMinutes, callStatus, callBackCustomer, callAnsweredBy, customerSatisfactionRating);
  111.  
  112. if(callCentre.isFull()) // if the call centre is full
  113. {
  114. System.out.println("The call centre is full");
  115. }
  116. else // if the call centre is not full, add the call to the system
  117. {
  118. callCentre.add(call);
  119. }
  120.  
  121. }
  122.  
  123. private static void option2(CallCentre callCentre) // remove a call
  124. {
  125.  
  126. }
  127.  
  128. }
  129.  
  130. private static void option3(CallCentre callCentre) // Update the call status
  131. {
  132.  
  133.  
  134. }
  135.  
  136. private static void option4(CallCentre callCentre) // Check if the call list is empty
  137. {
  138. if (callCentre.isEmpty()) // if the call centre is empty
  139. {
  140. System.out.println("The call list is empty");
  141. }
  142. else // if the call centre is not empty
  143. {
  144. System.out.println("The call list is not empty");
  145. }
  146.  
  147. }
  148.  
  149. private static void option5(CallCentre callCentre) // Check if the call list is full
  150. {
  151. if (callCentre.isFull()) // if the call centre is full
  152. {
  153. System.out.println("The call list is full");
  154. }
  155. else // if the call centre is not full
  156. {
  157. System.out.println("The call list is not full");
  158. }
  159.  
  160. }
  161.  
  162.  
  163. private static void option6(CallCentre callCentre) // Details of call
  164. {
  165. System.out.println();
  166.  
  167. char choice = ' '; // This is how the choic for a-e is decided.
  168.  
  169. do //loop for a-e
  170. {
  171. System.out.println();
  172. System.out.println("Call Centre System");
  173. System.out.println();
  174. System.out.println("1: Add a Call");
  175. System.out.println("2: Remove a call");
  176. System.out.println("3: Update call Status");
  177. System.out.println("4: Check if the call list is Empty");
  178. System.out.println("5: Check if the call list is Full");
  179. System.out.println("6: Call details...");
  180. System.out.println(" a. Display details of a specific call");
  181. System.out.println(" b. Display all calls");
  182. System.out.println(" c. Display Longest call");
  183. System.out.println(" d. Display Shortest call");
  184. System.out.println(" e. Display all calls above the suggested length of a call");
  185. System.out.println("7: Update suggested length of call");
  186. System.out.println("8: Exit System");
  187. System.out.println();
  188.  
  189. System.out.print("Enter choice [a-e]: ");
  190. choice = EasyScanner.nextChar(); //using a char
  191. System.out.println();
  192.  
  193. // menu options
  194. if(choice == 'a')
  195. {
  196. option6a(callCentre);
  197. }
  198. else if (choice == 'b')
  199. {
  200. option6b(callCentre);
  201. }
  202. else if (choice == 'c')
  203. {
  204. option6c(callCentre);
  205. }
  206. else if (choice == 'd')
  207. {
  208. option6d(callCentre);
  209. }
  210. else if (choice == 'e')
  211. {
  212. option6e(callCentre);
  213. }
  214.  
  215. }while (choice != 'd');
  216.  
  217. }
  218. private static void option7(CallCentre callCentre) // Update suggested length of call
  219. {
  220. System.out.print("Enter the new suggested length of each call: "); //The length of each call made
  221. int suggestedLengthOfCall = EasyScanner.nextInt();
  222.  
  223. }
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement