Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

Commit

Permalink
Update incident model
Browse files Browse the repository at this point in the history
  • Loading branch information
meiannn committed Oct 11, 2019
1 parent 02cc0f7 commit e60f0f4
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public Description() {
this.desc = "";
}


@Override
public String toString() {
return desc;
Expand Down
40 changes: 36 additions & 4 deletions src/main/java/seedu/address/model/incident/Incident.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
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;
Expand All @@ -13,6 +15,7 @@ public class Incident {
private Person operator;
private LocalDateTime dateTime;
private Vehicle car;
private IncidentID id;

//needs to be entered by operator
private Description incidentDesc;
Expand All @@ -26,14 +29,43 @@ public class 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;
//operator = autofilled when sign in
//location = prompt and return value from GUI
incidentDesc = new Description(); //prompt to fill in desc now. if n, empty desc, if yes, use string from GUI
//car = auto-assigned??
//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;
}
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/seedu/address/model/incident/IncidentID.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit e60f0f4

Please sign in to comment.