ace

supportsystem6

ace
Feb 10th, 2010
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. import java.util.HashSet;
  2. import java.util.ArrayList;
  3. /**
  4. * This class implements a technical support system.
  5. * It is the top level class in this project.
  6. * The support system communicates via text input/output
  7. * in the text terminal.
  8. *
  9. * This class uses an object of class InputReader to read input
  10. * from the user, and an object of class Responder to generate responses.
  11. * It contains a loop that repeatedly reads input and generates
  12. * output until the users wants to leave.
  13. *
  14. * @author Michael Kolling and David J. Barnes
  15. * @version 1.0
  16. */
  17. public class SupportSystem
  18. {
  19. private InputReader reader;
  20. private Responder responder;
  21.  
  22. /**
  23. * Creates a technical support system.
  24. */
  25. public SupportSystem()
  26. {
  27. reader = new InputReader();
  28. responder = new Responder();
  29. }
  30.  
  31. /**
  32. * Start the technical support system. This will print a welcome message and enter
  33. * into a dialog with the user, until the user ends the dialog.
  34. */
  35. public void start()
  36. {
  37. boolean finished = false;
  38.  
  39. printWelcome();
  40.  
  41. while(!finished) {
  42. ArrayList<String> input = reader.getInput();
  43. if(input.contains("bye")) {
  44. finished = true;
  45. }
  46. else {
  47. String response = responder.generateResponse(input);
  48. System.out.println(response);
  49. }
  50. }
  51. printGoodbye();
  52. }
  53.  
  54. /**
  55. * Print a welcome message to the screen.
  56. */
  57. private void printWelcome()
  58. {
  59. System.out.println("Welcome to the DodgySoft Technical Support System.");
  60. System.out.println();
  61. System.out.println("Please tell us about your problem.");
  62. System.out.println("We will assist you with any problem you might have.");
  63. System.out.println("Please type 'bye' to exit our system.");
  64. }
  65.  
  66. /**
  67. * Print a good-bye message to the screen.
  68. */
  69. private void printGoodbye()
  70. {
  71. System.out.println("Nice talking to you. Bye...");
  72. }
  73. }
  74.  
Add Comment
Please, Sign In to add comment