Langsung ke konten utama

Tugas PBO Psychological Support Chatbot


Hi! We're back again! This time I'm going to show you my recent project on making a chatbot for technical support, called Monokuro Boo. It's great for you if you have traumas, problems, distress, etc.
I'm using 3 classes for this chatbot, which are:
  1. SupportSystem
  2. InputReader
  3. Responder

These are the source code. Check it out!
  1. SupportSystem


       
     /**  
      * The main class for the support system, consisting greetings template.  
      *   
      * @author (Elkana Hans Widersen)  
      * @version (08.10.2018)  
      */  
     public class SupportSystem {  
       private InputReader reader;  
       private Responder responder;  
         
       /**   
        * Creates a technical support system.   
        */  
       public SupportSystem() {  
         reader = new InputReader();  
         responder = new Responder();  
       }  
         
       /**   
        * Start the technical support system. This will print a   
        * welcome message and enter into a dialog with the user,   
        * until the user ends the dialog.   
        */  
       public void start() {  
         boolean finished = false;  
         printWelcome();  
         while(!finished) {  
           String input = reader.getInput();  
           if(input.startsWith("bye")) finished = true;   
           else {  
             String response = responder.generateResponse();  
             System.out.println(response);  
           }  
         }  
         printGoodbye();  
       }  
         
       /**   
        * Print a welcome message to the screen.   
        */  
       private void printWelcome() {  
         System.out.println("Hi, I'm Monokuro Boo, your personal technical support system.\n");  
         System.out.println("Please tell me about your problem.");  
         System.out.println("I will assist you with any problem you might have.");  
         System.out.println("Please type 'bye' to exit my system.");  
       }  
         
       /**   
        * Print a good-bye message to the screen.   
        */  
       private void printGoodbye() {  
         System.out.println("Nice talking to you. Bye. . .");  
       }  
     }  
       
    
  2. InputReader


       
     /**  
      * Class specialized to read the user input.  
      *   
      * @author (Elkana Hans Widersen)  
      * @version (08.10.2018)  
      */  
       
     import java.util.Scanner;  
     public class InputReader {  
       public String getInput() {  
         Scanner sc = new Scanner(System.in);  
         String input = sc.nextLine();  
         return input;  
       }  
     }  
       
    
  3. Responder

       
     /**  
      * Class specialized to generate a response regarding of the input received.   
      *   
      * @author (Elkana Hans Widersen)  
      * @version (08.10.2018)  
      */  
       
     import java.util.Random;  
     public class Responder {  
       public Responder() {}  
         
       public String generateResponse() {  
         Random rand = new Random();  
         int n = rand.nextInt(8) + 1;  
         String response = "Hi";  
         switch(n) {  
           case 1: response = "That sounds interesting. Tell me more. . .";  
           case 2: response = "That probably shouldn't have happened";  
           case 3: response = "I'm sorry, I don't have the capability to process a response for that";  
           case 4: response = "Even so, it could be worse";  
           case 5: response = "You know, talking to you made me realize some things I didn't before";  
           case 6: response = "Well, that's awful.";  
           case 7: response = "Oh, is that so?";  
         }  
         return response;  
       }  
     }  
       
    
I will give you a quick photo of what this bot can do.

Have some time with Monokuro Boo. You might feel much better after chatting with her for a while. 👍👍👍

Thank you and see you next time!

Komentar

Postingan populer dari blog ini

Tugas PBO Auction Simulator

Hey, guys! Today I'm so excited to show you how to implement an Auction Simulator into Java. We are going to use 4 classes, which are: Auction Bid Lot Person You can check the source code of each classes below before we try to execute this program. Auction /** * A simple model of an auction * * @author Elkana Hans Widersen * @version 02.10.2018 */ import java.util.ArrayList; public class Auction { // The list of Lots in this auction. private ArrayList<Lot> lots; // The number that will be given to the next lot entered // into this auction. private int nextLotNumber; /** * Creates a new auction. */ public Auction() { lots = new ArrayList<Lot>(); nextLotNumber = 1; } /** * Enters a new lot into the auction. * @param description = A description of the lot. */ public void enterLot(String description) { lots.add(n

Tugas 3 PBO A

Hey guys! This time I have been working on making my own Ticket Machine using BlueJ. I am using 2 classes, which is Main and TicketMachine . TicketMachine /* * This class contains the declaration of the Ticket Machine we are going to use.. * * @author (Elkana Hans Widersen) * @version (17/9/2018) */ import java.util.Scanner; public class TicketMachine{ Scanner scan = new Scanner(System.in); // The price of a ticket from this machine. private int price; // The amount of money entered by a customer so far. private int balance; // The amount of tickets about to be printed. private int ticket; // The total amount of money collected by this machine. private int total; /* * Create a machine that issues tickets of the given price. * Note that the price must be greater than zero, and there * are no checks to ensure this. */ public TicketMachine(int ticketCost){

Fox and Rabbit Simulator

Hi guys! I'm going to show you a Fox and Rabbit Simulator made in BlueJ. We're going to use these classes Simulator SimulatorView Location Field FieldStats Counter Randomizer Rabbit Fox Here is the source code of those classes: Simulator import java.util.Random; import java.util.List; import java.util.ArrayList; import java.util.Iterator; import java.awt.Color; /** * A simple predator-prey simulator, based on a rectangular field * containing rabbits and foxes. * * @author Elkana Hans Widersen * @version 1.0 */ public class Simulator { /** * Constants representing configuration information for the simulation. */ private static final int def_width = 50; // The default width for the grid. private static final int def_depth = 50; // The default depth of the grid. private static final double foxProbability = 0.02; // The probability that a fo