Nama: Ayu Mutiara Sari
NRP: 05111740000149
Kelas: PBO A
1. Source Code Support System
2. Source Code Responder
3. Source Code InputReader
Hasil:
NRP: 05111740000149
Kelas: PBO A
1. Source Code Support System
/**
* Class ini digunakan untuk membuat support system.
*
* @author (Ayu Mutiara Sari)
* @version 01.01(10/8/2018)
*/
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("Hello");
System.out.println("=============================");
System.out.println("Tell me something I don't know!");
System.out.println("Say 'bye' to exit"); }
private void printGoodbye(){
System.out.println("Good Bye!.");
}
}
2. Source Code Responder
/**
* Write a description of class Responder here.
*
* @author (Ayu Mutiara Sari)
* @version 01.02(10/08/2018)
*/
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 "Wow! Cool!";
}
}
3. Source Code InputReader
/**
* Write a description of class input here.
*
* @author (Ayu Mutiara Sari)
* @version 01.02(10/08/2018)
*/
import java.util.Scanner;
public class InputReader
{
public String getInput()
{
Scanner input = new Scanner(System.in);
String in = input.nextLine();
return in;
}
}
Hasil:
0 komentar:
Posting Komentar