Minggu, 07 Oktober 2018

Support System

08 Oktober 2018

Support System

1. Source Code

a) Support System
 /**  
  * Suport System  
  *  
  * Sherly Rosa Anggraeni  
  * 05111740000018  
  */  
  public class SupportSystem   
  {   
   private InputReader reader;   
   private Responder responder;   
   public SupportSystem(){   
    reader = new InputReader();   
    responder = new Responder();   
   }   
   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();   
   }   
   private void printWelcome(){   
    System.out.println("Welcome");   
    System.out.println("Tell me about something");   
    System.out.println("type 'bye' to leave me");   
   }   
   private void printGoodbye(){   
    System.out.println("See ya :)");   
   }   
  }   

b) Input Reader
 /**  
  * Suport System  
  *  
  * Sherly Rosa Anggraeni  
  * 05111740000018  
  */  
  import java.util.Scanner;   
  public class InputReader   
  {   
   public InputReader(){}   
   public String getInput(){   
    String input;   
    Scanner sc = new Scanner(System.in);   
    input = sc.nextLine();   
    sc.close();   
    return input;   
   }   
  }   

c) Responder
 /**  
  * Suport System  
  *  
  * Sherly Rosa Anggraeni  
  * 05111740000018  
  */  
 public class Responder   
  {   
   public Responder(){   
   }   
   public String generateResponse(){   
    return "Hmm";    
   }   
  }   

2. Output


Tidak ada komentar:

Posting Komentar