bagusistighfar86

Untitled

Nov 11th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.96 KB | None | 0 0
  1. import java.util.*;
  2. /**
  3.  * This class implements a technical support system. It is the top-level class in this project.
  4.  * The support system communicates via text input/output in the text terminal. This class uses
  5.  * an object of class InputReader to read input from the user and an object of class Responder
  6.  * to generates output until the user wants to leave.
  7.  *
  8.  * @author      Muhammad Bagus Istighfar
  9.  * @version     0.1 - 11 November 2020
  10.  */
  11. public class SupportSystem
  12. {
  13.     public InputReader reader;
  14.     public Responder    responder;
  15.    
  16.     /**
  17.      * Creates a technical support system.
  18.      */
  19.     public SupportSystem()
  20.     {
  21.         reader = new InputReader();
  22.         responder = new Responder();
  23.     }
  24.     /**
  25.      * Start the technical support system. This will print a welcome message and enter into a
  26.      * dialog with the user, until the user ends the dialog.
  27.      */
  28.     public void start()
  29.     {
  30.         boolean finished = false;
  31.        
  32.         printWelcome();
  33.         while(!finished)
  34.         {
  35.             HashSet<String> input = reader.getInput();
  36.             if(input.contains("bye"))
  37.             {
  38.                 finished = true;
  39.             }
  40.             else
  41.             {
  42.                 String response = responder.generateResponse(input);
  43.                 System.out.println(response);
  44.             }
  45.         }
  46.         printGoodbye();
  47.     }
  48.    
  49.     /**
  50.      * Print a welcome message to the screen.
  51.      */
  52.     private void printWelcome()
  53.     {
  54.         System.out.println("Selamat datang di ChatSkuy Bot System");
  55.         System.out.println("Yuk share ceritamu, dan mulailah chat");
  56.         System.out.println("Ketik 'bye' untuk mengakhiri bot system\n");
  57.     }
  58.     /**
  59.      * Print a good-bye message to the screen.
  60.      */
  61.     private void printGoodbye()
  62.     {
  63.         System.out.println("Kamu sangat ramah. Semoga harimu menyenangkan!\n");
  64.         System.out.println("^_^ Good Bye ^_^");
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment