diff --git a/src/main/java/coreyscott/EstimatedCost.java b/src/main/java/coreyscott/EstimatedCost.java new file mode 100644 index 0000000..ecf6985 --- /dev/null +++ b/src/main/java/coreyscott/EstimatedCost.java @@ -0,0 +1,40 @@ +package coreyscott; + +public class EstimatedCost { + + private double labor; + private double parts; + private double emergencyFee; + + public EstimatedCost(int severity) { + // Example: base estimate by severity (you can tweak these numbers) + switch (severity) { + case 1: + labor = 50; parts = 25; emergencyFee = 0; + break; + case 2: + labor = 75; parts = 40; emergencyFee = 0; + break; + case 3: + labor = 100; parts = 75; emergencyFee = 50; + break; + case 4: + labor = 150; parts = 125; emergencyFee = 75; + break; + case 5: + labor = 250; parts = 200; emergencyFee = 100; + break; + default: + labor = 75; parts = 40; emergencyFee = 0; + } + } + + public double getTotal() { + return labor + parts + emergencyFee; + } + + public String getBreakdown() { + return String.format("Est. Cost -> Labor: $%.2f | Parts: $%.2f | Emergency: $%.2f | Total: $%.2f", + labor, parts, emergencyFee, getTotal()); + } +} \ No newline at end of file diff --git a/src/main/java/coreyscott/Main.java b/src/main/java/coreyscott/Main.java new file mode 100644 index 0000000..4bde7fd --- /dev/null +++ b/src/main/java/coreyscott/Main.java @@ -0,0 +1,78 @@ +package coreyscott; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + + List requests = new ArrayList<>(); + MaintenanceOffice office = new MaintenanceOffice(); + + requests.add(new MaintenanceRequest("Greg Brady", "102A", "Electrical", 5)); + requests.add(new MaintenanceRequest("Walter White", "203B", "HVAC", 4)); + requests.add(new MaintenanceRequest("Franklin Saint", "302C", "Plumbing", 3)); + + System.out.println("=== INITIAL REQUESTS ==="); + for (MaintenanceRequest request : requests) { + System.out.println(request); + System.out.println(request.getEstimatedCostBreakdown()); + + if (request.getIssueSeverity() >= 4) { + System.out.println("HIGH PRIORITY"); + } + + office.assignTech(request); + office.updateStatus(request, "DONE"); + office.closeRequest(request); + + System.out.println("---------------------"); + } + + Scanner scanner = new Scanner(System.in); + + while (true) { + System.out.print("Enter tenant name (or type 'done' to stop): "); + String name = scanner.nextLine(); + + if (name.equalsIgnoreCase("done")) { + break; + } + + System.out.print("Apartment number: "); + String apt = scanner.nextLine(); + + System.out.print("Issue type: "); + String issue = scanner.nextLine(); + + System.out.print("Severity (1-5): "); + int severity = Integer.parseInt(scanner.nextLine()); + + MaintenanceRequest newRequest = new MaintenanceRequest(name, apt, issue, severity); + requests.add(newRequest); + + System.out.println("Request logged successfully!"); + System.out.println(newRequest); + System.out.println(newRequest.getEstimatedCostBreakdown()); + + if (issue.equalsIgnoreCase("Electrical") && severity >= 4) { + System.out.println("WARNING: High severity electrical issue!"); + } + + if (severity == 5) { + System.out.println("Dispatch immediately!"); + } + + office.assignTech(newRequest); + office.updateStatus(newRequest, "DONE"); + office.closeRequest(newRequest); + + System.out.println("---------------------"); + } + + office.printDailyReport(requests); + + scanner.close(); + } +} \ No newline at end of file diff --git a/src/main/java/coreyscott/MaintenanceOffice.java b/src/main/java/coreyscott/MaintenanceOffice.java new file mode 100644 index 0000000..105e4c5 --- /dev/null +++ b/src/main/java/coreyscott/MaintenanceOffice.java @@ -0,0 +1,85 @@ +package coreyscott; + +import java.util.List; + +public class MaintenanceOffice { + + private static final String IN_PROGRESS = "IN_PROGRESS"; + private static final String DONE = "DONE"; + private static final String NEW = "NEW"; + + public void assignTech(MaintenanceRequest request) { + if (request.getIssueSeverity() >= 4) { + System.out.println("Senior tech has been assigned."); + } else { + System.out.println("Standard tech has been assigned."); + } + } + + public void updateStatus(MaintenanceRequest request, String newStatus) { + if (newStatus.equals(NEW) || newStatus.equals(IN_PROGRESS) || newStatus.equals(DONE)) { + request.setStatus(newStatus); + System.out.println("Status updated to: " + newStatus); + } else { + System.out.println("Invalid status. Only NEW, IN_PROGRESS, or DONE allowed."); + } + } + + public void closeRequest(MaintenanceRequest request) { + if (request.getStatus().equals(DONE)) { + System.out.println("Request closed successfully."); + } else { + System.out.println("Request cannot be closed unless status is DONE."); + } + } + + public void printDailyReport(List requests) { + int open = 0, closed = 0; + int low = 0, medium = 0, high = 0; + + String mostCommonIssue = ""; + int maxCount = 0; + + for (MaintenanceRequest request : requests) { + + if (request.getStatus().equals(DONE)) { + closed++; + } else { + open++; + } + + int severity = request.getIssueSeverity(); + if (severity <= 2) { + low++; + } else if (severity == 3) { + medium++; + } else { + high++; + } + + int count = 0; + String currentIssue = request.getIssueType(); + + for (MaintenanceRequest r : requests) { + if (r.getIssueType().equalsIgnoreCase(currentIssue)) { + count++; + } + } + + if (count > maxCount) { + maxCount = count; + mostCommonIssue = currentIssue; + } + } + + System.out.println("\n===== DAILY REPORT ====="); + System.out.println("Total requests: " + requests.size()); + System.out.println("Open: " + open + " | Closed: " + closed); + System.out.println("Low: " + low + " | Medium: " + medium + " | High: " + high); + System.out.println("Most common issue: " + mostCommonIssue); + + if (high > 3) { + System.out.println("WARNING: Too many high priority requests!"); + } + } +} \ No newline at end of file diff --git a/src/main/java/coreyscott/MaintenanceRequest.java b/src/main/java/coreyscott/MaintenanceRequest.java new file mode 100644 index 0000000..04b5c0d --- /dev/null +++ b/src/main/java/coreyscott/MaintenanceRequest.java @@ -0,0 +1,97 @@ +package coreyscott; + +public class MaintenanceRequest { + + private String tenantName; + private String apartmentNumber; + private String issueType; + private int issueSeverity; + private String status; + private EstimatedCost estimatedCost; + + public MaintenanceRequest() { + this.tenantName = ""; + this.apartmentNumber = ""; + this.issueType = ""; + this.issueSeverity = 1; + this.status = "NEW"; + this.estimatedCost = new EstimatedCost(1); + } + + public MaintenanceRequest(String tenantName, String apartmentNumber, String issueType, int issueSeverity) { + this.tenantName = tenantName; + this.apartmentNumber = apartmentNumber; + this.issueType = issueType; + setIssueSeverity(issueSeverity); + this.status = "NEW"; + } + + public String getTenantName() { + return tenantName; + } + + public String getApartmentNumber() { + return apartmentNumber; + } + + public String getIssueType() { + return issueType; + } + + public int getIssueSeverity() { + return issueSeverity; + } + + public String getEstimatedCostBreakdown() { + return estimatedCost.getBreakdown(); + } + + public double getEstimatedTotalCost() { + return estimatedCost.getTotal(); + } + + public String getStatus() { + return status; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public void setApartmentNumber(String apartmentNumber) { + this.apartmentNumber = apartmentNumber; + } + + public void setIssueType(String issueType) { + this.issueType = issueType; + } + + public void setIssueSeverity(int issueSeverity) { + if (issueSeverity >= 1 && issueSeverity <= 5) { + this.issueSeverity = issueSeverity; + this.estimatedCost = new EstimatedCost(issueSeverity); + } else { + System.out.println("Invalid severity. Defaulting to 1."); + this.issueSeverity = 1; + this.estimatedCost = new EstimatedCost(1); + } + } + + public void setStatus(String status) { + if (status.equals("NEW") || status.equals("IN_PROGRESS") || status.equals("DONE")) { + this.status = status; + } else { + System.out.println("INVALID STATUS UPDATE"); + } + } + + @Override + public String toString() { + return "Tenant: " + tenantName + + " | Apt: " + apartmentNumber + + " | Issue: " + issueType + + " | Severity: " + issueSeverity + + " | Status: " + status + + " | Estimated Total: $" + getEstimatedTotalCost(); + } +} \ No newline at end of file diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 435139b..a04bf99 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -4,14 +4,6 @@ // click the icon in the gutter. public class Main { public static void main(String[] args) { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - System.out.println("i = " + i); - } } } \ No newline at end of file