Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed parameters for person class and created a patrol resource class #21

26 changes: 26 additions & 0 deletions OffenceList.txt
@@ -0,0 +1,26 @@
abetment
accident
unsound
piracy
rioting
dispute
drug offences
homicide
murder
manslaughter
fire
suicide
attempted suicide
assault
kidnap
outrage of modesty
rape
robbery
gunman
hostage
cheating
house-break
corruption
wanted
chemical attack

2 changes: 1 addition & 1 deletion src/seedu/addressbook/Main.java
Expand Up @@ -14,7 +14,7 @@
public class Main extends Application implements Stoppable{

/** Version info of the program. */
public static final String VERSION = "AddressBook Level 3 - Version 1.0";
public static final String VERSION = "EX-SI-53 - Version 1.0";

private Gui gui;

Expand Down
29 changes: 14 additions & 15 deletions src/seedu/addressbook/commands/AddCommand.java
Expand Up @@ -14,11 +14,10 @@ public class AddCommand extends Command {

public static final String COMMAND_WORD = "add";

public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Adds a person to the address book. "
+ "Contact details can be marked private by prepending 'p' to the prefix.\n\t"
+ "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...\n\t"
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Adds a person to the system. "
+ "Parameters: NAME n/NRIC p/POSTALCODE s/STATUS [o/PASTOFFENSES]...\n\t"
+ "Example: " + COMMAND_WORD
+ " John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney";
+ " John Doe n/s1234567a p/510246 s/excon o/theft o/drugs";

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
Expand All @@ -31,20 +30,20 @@ public class AddCommand extends Command {
* @throws IllegalValueException if any of the raw values are invalid
*/
public AddCommand(String name,
String phone, boolean isPhonePrivate,
String email, boolean isEmailPrivate,
String address, boolean isAddressPrivate,
Set<String> tags) throws IllegalValueException {
final Set<Tag> tagSet = new HashSet<>();
for (String tagName : tags) {
tagSet.add(new Tag(tagName));
String nric,
String postalCode,
String status,
Set<String> pastOffenses) throws IllegalValueException {
final Set<Offense> pastOffenseSet = new HashSet<>();
for (String offenseName : pastOffenses) {
pastOffenseSet.add(new Offense(offenseName));
}
this.toAdd = new Person(
new Name(name),
new Phone(phone, isPhonePrivate),
new Email(email, isEmailPrivate),
new Address(address, isAddressPrivate),
tagSet
new NRIC(nric),
new PostalCode(postalCode),
new Status(status),
pastOffenseSet
);
}

Expand Down
44 changes: 44 additions & 0 deletions src/seedu/addressbook/data/PoliceOfficers/Case.java
@@ -0,0 +1,44 @@
package seedu.addressbook.data.PoliceOfficers;

import seedu.addressbook.data.exception.IllegalValueException;

import java.sql.Timestamp;
import java.time.Instant;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Case {

public static final String EXAMPLE_CASE = "PO3, robbery, GPS coordinates, timestamp";
public static final String MESSAGE_CASE_CONSTRAINTS = "Case must have: PatrolID, message, GPS, timestamp";

public static final PatrolID attendingPO;
public String caseMessage;
//public GPS coordinates;
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
public static final String caseDateTime;

private String SPACE = ", ";
public String value;

public Case(){
this.attendingPO = null;
this.caseMessage = "none";
//this.GPS = null
this.caseDateTime = null;
}
public Case(PatrolID patrolIDNo, String message, /*GPS*/ Date dateTime) throws IllegalValueException{
if (!isValidCase){
throw new IllegalValueException(MESSAGE_CASE_CONSTRAINTS);
}
this.attendingPO = patrolIDNo;
this.caseMessage = message;
//this.GPSCoordinates = GPS;
this.caseDateTime = dateFormat.format(dateTime);
this.value = patrolIDNo.patrolID + SPACE + caseMessage + SPACE + /*GPS*/ caseDateTime;

}

public static boolean isValidCase() //to be confirmed

}
52 changes: 52 additions & 0 deletions src/seedu/addressbook/data/PoliceOfficers/PatrolID.java
@@ -0,0 +1,52 @@
package seedu.addressbook.data.PoliceOfficers;

import seedu.addressbook.data.exception.IllegalValueException;

/**
* Represents a Patrol resource's ID in EX-SI-53.
* Guarantees: immutable; is valid as declared in {@link #isValidID(int)}
*/

public class PatrolID {
public static final String EXAMPLE = "PO1";
public static final String MESSAGE_ID_CONSTRAINTS = "Patrol ID has to be a number excluding 0, and must not be an existing ID";
public static final String PATROL_ID_PREFIX = "PO";
public static final int CONSTRAINT = 0;

public final int ID;
public final String patrolID;

public PatrolID (int identification) throws IllegalValueException{
if (!isValidID(identification)){
throw new IllegalValueException(MESSAGE_ID_CONSTRAINTS);
}
this.ID = identification;
this.patrolID = PATROL_ID_PREFIX + Integer.toString(identification);
}

/**
* Validates given ID.
*
* @throws IllegalValueException if given ID is invalid.
*/

public static boolean isValidID(int test) {return test > CONSTRAINT; }

@Override
public String toString() {
return patrolID;
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof PatrolID // instanceof handles nulls
&& this.patrolID.equals(((PatrolID) other).patrolID)); // state check
}

@Override
public int hashCode() {
return patrolID.hashCode();
}

}
75 changes: 75 additions & 0 deletions src/seedu/addressbook/data/PoliceOfficers/PatrolResource.java
@@ -0,0 +1,75 @@
package seedu.addressbook.data.PoliceOfficers;


/**
* Represents a Patrol Resource in the system.
* Guarantees: details are present and not null, field values are validated.
*/
public class PatrolResource {
public PatrolID patrolID;
public State state;
public Case currentCase;


/**
* Assumption: Every field must be present and not null (except current case).
*/
public PatrolResource(PatrolID patrolID, State state, Case currentCase) {
this.patrolID = patrolID;
this.state = state;
this.currentCase = (state.currentState == state.FREE) ? new Case() : currentCase;
}

public PatrolResource(ReadOnlyPatrolResource source) {
this(source.getPatrolID(), source.getState(), source.getCurrentCase());
}

public Case RA(){
//would generate timestamp and GPS
//sent to HQP 'inbox'
}

public Case RB(){
//would generate timestamp and GPS
//sent to HQP 'inbox'
}

public Case RF(){
//would generate timestamp and GPS
//sent to HQP 'inbox'
}

@Override
public PatrolID getPatrolID() {
return patrolID;
}

@Override
public State getState() {
return state;
}

@Override
public Case getCurrentCase() {
return currentCase;
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof ReadOnlyPatrolResource // instanceof handles nulls
&& this.isSameStateAs((ReadOnlyPatrolResource) other));
}

@Override
public int hashCode() {
// use this method for custom fields hashing instead of implementing your own
return Objects.hash(patrolID, state, currentCase);
}

@Override
public String toString() {
return getAsTextShowAll();
}

}
@@ -0,0 +1,42 @@
package seedu.addressbook.data.PoliceOfficers;


/**
* A read-only immutable interface for a Patrol Resource in the system.
* Implementations should guarantee: details are present and not null, field values are validated.
*/
public interface ReadOnlyPatrolResource {

PatrolID getPatrolID();
State getState();
Case getCurrentCase();
Case RA(); //request ambulance
Case RB(); //request backup, can be other POs or can be enhanced like SWAT
Case RF(); //request fire fighters


/**
* Returns true if the values inside this object is same as those of the other (Note: interfaces cannot override .equals)
*/
default boolean isSameStateAs(ReadOnlyPatrolResource other) {
return other == this // short circuit if same object
|| (other != null // this is first to avoid NPE below
&& other.getPatrolID().equals(this.getPatrolID()) // state checks here onwards
&& other.getState().equals(this.getState())
&& other.getCurrentCase().equals(this.getCurrentCase()));

}


/**
* Formats a patrol resource as text, showing all details.
*/
default String getAsTextHidePrivate() {
final StringBuilder builder = new StringBuilder();
builder.append(" Patrol ID: ").append(getPatrolID());
builder.append(" State: ").append(getState());
builder.append(" Current Case: ").append(getCurrentCase());

return builder.toString();
}
}
47 changes: 47 additions & 0 deletions src/seedu/addressbook/data/PoliceOfficers/State.java
@@ -0,0 +1,47 @@
package seedu.addressbook.data.PoliceOfficers;

import seedu.addressbook.data.exception.IllegalValueException;

/**
* Represents a Patrol resource's current state in EX-SI-53.
* Guarantees: only 2 possible states; is valid as declared in {@link #isValidState(String)}
*/

public class State {

public static final String EXAMPLE_STATE = "free";
public static final String MESSAGE_STATE_CONSTRAINTS = "Patrol resource can either be 'free' or 'engaged'";
public static final String FREE = "free";
public static final String ENGAGED = "engaged";
public static final String DEFAULT_CASE = "none";
public String currentState;


public State(String state) throws IllegalValueException{
state = state.trim();
if (!isValidState(state)){
throw new IllegalValueException(MESSAGE_STATE_CONSTRAINTS);
}
this.currentState = state;
}

public boolean isValidState(String test) {return test == FREE || test == ENGAGED;}

@Override
public String toString() {
return currentState;
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof PatrolID // instanceof handles nulls
&& this.currentState.equals(((State) other).currentState)); // state check
}

@Override
public int hashCode() {
return currentState.hashCode();
}

}
2 changes: 1 addition & 1 deletion src/seedu/addressbook/data/person/NRIC.java
Expand Up @@ -6,7 +6,7 @@
import java.util.List;

/**
* Represents a Person's identification number(NRIC or FIN) in the address book.
* Represents a Person's identification number(NRIC or FIN) in the EX-SI-53.
* Guarantees: immutable; is valid as declared in {@link #isValidNRIC(String)}
*/

Expand Down