This repository has been archived by the owner on Apr 13, 2020. It is now read-only.
forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nus-cs2103-AY1920S1#3 from hellopanda128/branch-in…
…cident-model Branch incident model
- Loading branch information
Showing
3 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/seedu/address/model/incident/Description.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/seedu/address/model/incident/IncidentID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |