Nama : Bobbi Aditya
NRP : 05111740000099
Kelas : PBO-A
Disini saya membuat sebuah technical support system dengan 3 kelas, yakni:
- SupportSystem
- Responder
- InputReader
Berikut saya sertakan source code dari class saya:
Responder
/**
* Write a description of class Responder here.
*
* @author Bobbi Aditya
* @version 1.00
*/
public class Responder
{
// instance variables - replace the example below with your own
public Responder()
{
}
public String generateResponse()
{
return "That sounds interesting. Tell me more..." ;
}
}
InputReader import java.util.Scanner;
/**
* Write a description of class InputReader here.
*
* @author Bobbi Aditya
* @version 1.00
*/
public class InputReader
{
public String getInput()
{
Scanner sc=new Scanner(System.in);
String inputan;
System.out.print(">>");
inputan = sc.next();
return inputan;
}
}
SupportSystem /**
* Write a description of class SupportSystem here.
*
* @author Bobbi Aditya
* @version 1.00
*/
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 to the Bobbi Aditya Technical Support System." );
System.out.println("-----------------------------------------------------");
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." );
}
private void printGoodbye()
{
System.out.println("Nice talking to you. Bye..");
}
}
Hasilnya adalah seperti di bawah ini
Comments
Post a Comment