Advertisement
lamaulfarid

SupportSystem

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