Advertisement
mnaufaldillah

SupportSystem Tugas 5

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