Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

personquery 4

By: ace on Feb 10th, 2010  |  syntax: None  |  size: 2.14 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.             String trueInput = reader.getTrueInput();
  44.  
  45.             if(input.contains("bye")) {
  46.                 finished = true;
  47.             }
  48.             else {
  49.                 String response = responder.generateResponse(input);
  50.                 System.out.println(response);
  51.             }
  52.         }
  53.         printGoodbye();
  54.     }
  55.  
  56.     /**
  57.      * Print a welcome message to the screen.
  58.      */
  59.     private void printWelcome()
  60.     {
  61.         System.out.println("Welcome to the DodgySoft Technical Support System.");
  62.         System.out.println();
  63.         System.out.println("Please tell us about your problem.");
  64.         System.out.println("We will assist you with any problem you might have.");
  65.         System.out.println("Please type 'bye' to exit our system.");
  66.     }
  67.  
  68.     /**
  69.      * Print a good-bye message to the screen.
  70.      */
  71.     private void printGoodbye()
  72.     {
  73.         System.out.println("Nice talking to you. Bye...");
  74.     }
  75. }