Tugas PBO - Tech Support

Nama: Donny Fitrado
NRP: 05111740000171
Kelas: PBO A

1. SupportSystem
 /**  
  * Write a description of class SupportSystem here.  
  *  
  * @author (Donny Fitrado)  
  * @version (8-10-18)  
  */  
 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(   
    "Welcome to the DodgySoft Technical Support System.");   
    System.out.println();   
    System.out.println("Please tell us about your problem.");   
    System.out.println(   
    "We will assist you with any problem you might have.");   
    System.out.println(   
    "Please type 'bye' to exit our system.");   
   }   
   /**   
   * Print a good-bye message to the screen.   
   */   
   private void printGoodbye()   
   {   
    System.out.println("Nice talking to you. Bye. . .");   
   }   
  }   


2. InputReader
 /**  
  * Write a description of class InputReader here.  
  *  
  * @author (Donny Fitrado)  
  * @version (8-10-18)  
  */  
 import java.util.Scanner;   
  public class InputReader   
  {   
   private Scanner sc;   
   public InputReader(){   
    sc = new Scanner(System.in);   
   }   
   public String getInput(){   
    String input;   
    input = sc.nextLine();   
    return input;   
   }    
  }   


3. Responder
 /**  
  * Write a description of class Responder here.  
  *  
  * @author (Donny Fitrado)  
  * @version (8-10-18)  
  */  
 public class Responder   
  {   
   /**   
   * Construct a Responder - nothing to do   
   */   
   public Responder()   
   {   
   }   
   /**   
   * Generate a response.   
   * @return A string that should be displayed as the   
   * response   
   */   
   public String generateResponse()   
   {   
    return "That sounds interesting. Tell me more. . .";   
   }   
  }   

Workpacenya:

Ketika dijalankan:

Terima kasih dan mohon maaf apabila ada kesalahan.

Comments

Popular posts from this blog

Tugas 2 - Pemrograman Orientasi Objek

Tugas 5 PBKK A