document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2.  
  3. /**
  4.  * Implements a technical support system. It contains a loop that repeatedly
  5.  * reads input and generates output until the user wnats to leave
  6.  *
  7.  * @author (prabu)
  8.  * @version (2020/11/9)
  9.  */
  10. import java.util.*;
  11.  
  12. public class SupportSystem
  13. {
  14.     private InputReader reader;
  15.     private Responder responder;
  16.    
  17.     /**
  18.      * Create a technical support system
  19.      */
  20.     public SupportSystem()
  21.     {
  22.         reader = new InputReader();
  23.         responder = new Responder();
  24.     }
  25.    
  26.     /**
  27.      * Start the technical support system. This will print a welcome message
  28.      * and enter into a dialog with the user, until the user ends the dialog.
  29.      */
  30.     public void start()
  31.     {
  32.         boolean finished = false;
  33.         printWelcome();
  34.         printFAQ();
  35.         while(!finished)
  36.         {
  37.             String option = reader.getOptionInput();
  38.             if(option.compareTo("1") == 0)
  39.             {
  40.                System.out.println(responder.getFAQ(1));
  41.             }
  42.             else if(option.compareTo("2") == 0)
  43.             {
  44.                System.out.println(responder.getFAQ(2));
  45.             }
  46.             else if(option.compareTo("3") == 0)
  47.             {
  48.                 System.out.println(responder.getFAQ(3));
  49.             }
  50.             else if(option.compareTo("4")==0)
  51.             {
  52.                 boolean finish = false;
  53.                 System.out.println("******");
  54.                 System.out.println("Tell us about your problem!");
  55.                 System.out.println("(Type \'bye\' to exit the system)");
  56.                 while(!finish)
  57.                 {
  58.                     HashSet<String> input = reader.getInput();
  59.                     if(input.contains("bye"))
  60.                     {
  61.                         finish = true;
  62.                         finished = true;
  63.                     }
  64.                     else
  65.                     {
  66.                         String response = responder.generateResponse(input);
  67.                         System.out.println(response);
  68.                     }
  69.                 }
  70.             }
  71.             else if(option.compareTo("bye")==0)
  72.             {
  73.                 break;
  74.             }
  75.             else
  76.             {
  77.                 System.out.println("Invalid Input!\\n");
  78.             }        
  79.         }
  80.         printGoodBye();
  81.     }
  82.  
  83.  
  84.     /**
  85.      * Print the FAQ message to the screen
  86.      */
  87.     private void printFAQ()
  88.     {
  89.         System.out.println("1. "+
  90.         "The program won\'t start.");
  91.         System.out.println("2. "+
  92.         "The program won\'t exit.");
  93.         System.out.println("3. "+
  94.         "The program is running slow.");
  95.         System.out.println("4. "+
  96.         "...or tell us your problems.");
  97.     }
  98.    
  99.     /**
  100.      * Print Welcome message to the screen
  101.      */
  102.     private void printWelcome()
  103.     {
  104.         System.out.println("Welcome to Technical Support System!\\n"+
  105.         "***");
  106.         System.out.println(responder.generateGreeting() +
  107.         "Is there anything I can help you with?\\n"+
  108.         "(Type \'bye\' to exit our system)");
  109.     }
  110.    
  111.    
  112.     /**
  113.      * Print goodbye message to the screen
  114.      */
  115.     private void printGoodBye()
  116.     {
  117.         System.out.println("Nice talking to you. Bye...");
  118.     }
  119. }  
  120.    
');