Issue resolution
// Define the interfaces interface Customer { String getId(); String getName(); void raiseIssue(Issue issue); } interface SupportAgent { String getId(); String getName(); void resolveIssue(Issue issue); } interface Issue { String getId(); String getDescription(); String getStatus(); // e.g., "Open", "Resolved" void setStatus(String status); } interface IssueResolutionSystem { void addIssue(Issue issue); Issue getIssueById(String id); void assignIssueToAgent(Issue issue, SupportAgent agent); void resolveIssue(Issue issue); } // Implement the classes class CustomerImpl implements Customer { private String id; private String name; public CustomerImpl(String id, String name) { this.id = id; this.name = name; } @Override public String getId() { return id; } @Override public String getName() { return name; } @Override public void raiseIssue(Issue issue) { System.out.println(name + " raised an issue: " + issue.getDescription()); } } class SupportAgentImpl implements SupportAgent { private String id; private String name; public SupportAgentImpl(String id, String name) { this.id = id; this.name = name; } @Override public String getId() { return id; } @Override public String getName() { return name; } @Override public void resolveIssue(Issue issue) { issue.setStatus("Resolved"); System.out.println(name + " resolved the issue: " + issue.getId()); } } class IssueImpl implements Issue { private String id; private String description; private String status; public IssueImpl(String id, String description) { this.id = id; this.description = description; this.status = "Open"; } @Override public String getId() { return id; } @Override public String getDescription() { return description; } @Override public String getStatus() { return status; } @Override public void setStatus(String status) { this.status = status; } } class IssueResolutionSystemImpl implements IssueResolutionSystem { private Map<String, Issue> issues = new HashMap<>(); private Map<Issue, SupportAgent> issueAssignments = new HashMap<>(); @Override public void addIssue(Issue issue) { issues.put(issue.getId(), issue); } @Override public Issue getIssueById(String id) { return issues.get(id); } @Override public void assignIssueToAgent(Issue issue, SupportAgent agent) { issueAssignments.put(issue, agent); System.out.println("Assigned issue " + issue.getId() + " to agent " + agent.getName()); } @Override public void resolveIssue(Issue issue) { SupportAgent agent = issueAssignments.get(issue); if (agent != null) { agent.resolveIssue(issue); } else { System.out.println("No agent assigned to issue " + issue.getId()); } } } // Example usage public class Main { public static void main(String[] args) { Customer customer = new CustomerImpl("C1", "John Doe"); SupportAgent agent = new SupportAgentImpl("A1", "Alice Smith"); IssueResolutionSystem system = new IssueResolutionSystemImpl(); Issue issue = new IssueImpl("I1", "Unable to access account"); customer.raiseIssue(issue); system.addIssue(issue); system.assignIssueToAgent(issue, agent); system.resolveIssue(issue); } }
Leave a Comment