Tugas Pertemuan 7 PBO
Nama : Moh. Rizky Rahmadian Makkani
NRP : 5025231035
Kelas : PBO A
Tugas Pertemuan 7 : PBO
Code Main.java :
public class Main {
public static void main(String[] args) {
SupportSystem supportSystem = new SupportSystem();
supportSystem.start();
}
}
Code SupportSystem.java :
public class SupportSystem {
private InputReader reader;
private Responder responder;
public SupportSystem() {
reader = new InputReader();
responder = new Responder();
}
public void start() {
System.out.println("Welcome to NigTech Support. Hello! How can I assist you today?");
System.out.println("Please type \"bye\" to exit.");
while (true) {
System.out.print("> ");
String input = reader.getInput();
if (input.equalsIgnoreCase("bye")) {
break;
}
String response = responder.generateResponse(input);
System.out.println(response);
}
System.out.println("Thank you for your patience. I’ve escalated your issue, and you’ll hear back from us shortly.");
}
}
Code InputReader.java :
import java.util.Scanner;
public class InputReader {
private Scanner scanner;
public InputReader() {
scanner = new Scanner(System.in);
}
public String getInput() {
return scanner.nextLine();
}
}
Code Responder.java :
import java.util.HashMap;
import java.util.Map;
public class Responder {
private Map<String, String> responses;
public Responder() {
responses = new HashMap<>();
responses.put("update",
"Good news! The update is now available. Please try the update, and let us know if you encounter any issues.");
responses.put("solution",
"This issue requires expertise from our technical team. They’re working on a solution, and we’ll keep you informed on any progress.");
responses.put("error",
"We apologize for the inconvenience. It looks like an error has occurred. Could you please provide more details or a screenshot? This will help us identify the issue faster.");
}
public String generateResponse(String input) {
for (String keyword : responses.keySet()) {
if (input.toLowerCase().contains(keyword)) {
return responses.get(keyword);
}
}
return "We appreciate you contacting us. Could you clarify your request or describe the issue you’re experiencing? This will help us direct you to the right support or solution.";
}
}
Output :
Komentar
Posting Komentar