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.
- Loading branch information
Showing
3 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -19,7 +19,6 @@ 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
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; | ||
} | ||
} |