diff --git a/src/main/java/seedu/address/model/incident/Description.java b/src/main/java/seedu/address/model/incident/Description.java new file mode 100644 index 00000000000..39b2a6f2387 --- /dev/null +++ b/src/main/java/seedu/address/model/incident/Description.java @@ -0,0 +1,26 @@ +package seedu.address.model.incident; + +public class Description { + private String desc; + + /** + * Creates a filled Description. + * @param desc the description of the event filled in by the operator. + */ + public Description(String desc) { + this.desc = desc; + } + + /** + * Creates a new Description that is empty. + * Used to facilitate fast creation of incident reports, descriptions can be added during edits. + */ + public Description() { + this.desc = ""; + } + + @Override + public String toString() { + return desc; + } +} diff --git a/src/main/java/seedu/address/model/incident/Incident.java b/src/main/java/seedu/address/model/incident/Incident.java new file mode 100644 index 00000000000..2e41971eaf5 --- /dev/null +++ b/src/main/java/seedu/address/model/incident/Incident.java @@ -0,0 +1,84 @@ +package seedu.address.model.incident; +import java.time.LocalDateTime; +import java.util.Scanner; + +import seedu.address.model.person.Person; +import seedu.address.model.vehicle.District; +import seedu.address.model.vehicle.Vehicle; + +/** + * Represents an incident report in the IMS. + */ +public class Incident { + + //is autofilled + private Person operator; + private LocalDateTime dateTime; + private Vehicle car; + private IncidentID id; + + //needs to be entered by operator + private Description incidentDesc; + private District location; + private String callerNumber; + + + /** + * Creates a new Incident report, fields will be filled in through prompts in the GUI. + * @param caller is the phone number of the caller that reported the incident. + */ + + public Incident(String caller) { + //this.operator = autofilled on sign in + this.dateTime = LocalDateTime.now(); + this.id = new IncidentID(dateTime.getMonthValue(), dateTime.getYear()); + this.incidentDesc = promptForDescription(); + this.location = promptForLocation(); + this.callerNumber = caller; + //this.car = VehicleAssigner.assignVehicle(location); + } + + + /** + * static method to prompt operator for incident location + * @return district which will be stored to location + */ + public static District promptForLocation() { + System.out.println("Enter location:"); //need to change to GUI prompt + Scanner sc = new Scanner(System.in); //need to change to GUI input + String dist = sc.next(); + while(!District.isValidDistrict(dist)) { + System.out.println("Please enter a valid district"); + dist = sc.next(); + } + return new District(dist); + } + + public static Description promptForDescription() { + System.out.println("Enter incident description now? y/n"); //change to GUI + Scanner sc = new Scanner(System.in); //change to GUI + String desc = ""; + if(sc.next().equals("y")) { + System.out.println("Please enter description:"); + desc = sc.nextLine(); + } + return new Description(desc); + } + + + public LocalDateTime getTime() { + return this.dateTime; + } + + public Description getDesc() { + return this.incidentDesc; + } + + public String getCallerNumber() { + return this.callerNumber; + } + + public Vehicle getCar() { + return car; + } +} diff --git a/src/main/java/seedu/address/model/incident/IncidentID.java b/src/main/java/seedu/address/model/incident/IncidentID.java new file mode 100644 index 00000000000..a6053bffcd5 --- /dev/null +++ b/src/main/java/seedu/address/model/incident/IncidentID.java @@ -0,0 +1,39 @@ +package seedu.address.model.incident; + +/** + * Generates Incident ID for the incident in this format: MMYYYYXXXX + * MM = Month of incident + * YYYY = Year of incident + * XXXX = incident number of the month + */ + +public class IncidentID { + private static int PREVIOUSM = 0; + private int mm; + private int yyyy; + private static int XXXX = 0; + private String ID; + + /** + * Generates the ID for the incident based on the following inputs + * @param mm month of incident + * @param yyyy year of incident + */ + public IncidentID(int mm, int yyyy) { + if(PREVIOUSM != mm) { + PREVIOUSM = mm; + XXXX = 0; + } else { + XXXX++; + } + + this.mm = mm; + this.yyyy = yyyy; + int temp = mm * 100000000 + yyyy * 1000 + XXXX; + this.ID = String.format("%10d", temp); + } + + public String getID() { + return this.ID; + } +}