PBO7 - Membuat Tech Support dalam BlueJ

TUGAS 7 - Pemrograman Berbasis Objek
Membuat Tech Support dalam program BlueJ
Nama : Bastian Farandy
NRP : 05111740000190
Kelas : Pemrograman Berbasis Objek A

Source Code :

Support System

 /**  
  * Technical Support System, communicates via text in input/output terminal.  
  * Reference : BlueJ Ebook in Chapter 5.2  
  * @author Bastian Farandy  
  * @version 0.1  
  */  
 public class SupportSystem  
 {  
   private InputReader reader;  
   private Responder responder;  
   //create a technical support system.  
   public SupportSystem()  
   {  
     reader = new InputReader();  
     responder = new Responder();  
   }  
   //function to start the technical support system.  
   //greeting the user with a welcome message.  
   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();   
  }   
   //function to print welcome message.  
   private void printWelcome()  
   {  
     System.out.println("Welcome to the DodgySoft Technical Support System.");  
     System.out.println("Please tell us about your problem.");  
     System.out.println("We will guide you with any problem you may have.");  
     System.out.println("To exit, just type 'bye'.");  
   }  
   //function to print Goodbye message.  
   private void printGoodbye()  
   {  
     System.out.println("Thankyou for using our Technical Support."  
     + " we hope to see you soon.");  
   }  
 }  

Responder

 import java.util.ArrayList;  
 import java.util.Random;  
 /**  
  * Generate Automatic Response to the user.  
  * Reference : BlueJ Ebook Chapter 5.2  
  * @author Bastian Farandy  
  * @version 0.1  
  */  
 public class Responder  
 {  
   private Random randomGenerator;  
   private ArrayList<String> responses;  
   //function to create a Responder.  
   public Responder()  
   {  
     randomGenerator = new Random();  
     responses = new ArrayList<String>();  
     fillResponses();  
   }  
   //function to generate a response.  
   public String generateResponse()  
   {  
     int index = randomGenerator.nextInt(responses.size());  
     return responses.get(index);  
   }  
   //function to list the default responses.  
   private void fillResponses()  
   {  
     responses.add("That sounds odd. Could you describe \n" +  
            "that problem in more detail?");  
     responses.add("No other customer has ever \n" +  
            "complained about this before. \n" +  
            "What is your system configuration?");  
     responses.add("That’s a known problem with Vista." +  
            "Windows 7 is much better.");  
     responses.add("I need a bit more information on that.");  
     responses.add("Have you checked that you do not \n" +  
            "have a dll conflict?");  
   }  
   }  

InputReader

 import java.util.Scanner;  
 import java.util.HashSet;  
 /**  
  * Write a description of class InputReader here.  
  *  
  * @author Bastian Farandy  
  * @version 0.1  
  */  
 public class InputReader  
 {  
   private Scanner reader;  
   public InputReader()  
   {  
     reader = new Scanner(System.in);  
   }  
   public String getInput()   
   {   
     String input = reader.nextLine();   
     return input;   
   }   
 }  

Screenshot


Keterangan :
SupportSystem sebagai class utama, yang menghandle jalannya program, hingga selesai.
Responder sebagai class yang menghandle respon secara otomatis kepada user.
InputReader sebagai class yang menghandle inputan user kedalam terminal.


Comments

Popular posts from this blog

PWEB5 - Membuat Form Pembayaran Air

EAS - PWEB - Membuat Sistem PPDB Online

MPPLC - FP