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
35 changes: 19 additions & 16 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 d/DATEOFBIRTH p/POSTALCODE s/STATUS w/WANTEDFOR [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 d/1996 p/510246 s/xc w/none 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,24 @@ 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 dateOfBirth,
String postalCode,
String status,
String wantedFor,
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 DateOfBirth(dateOfBirth),
new PostalCode(postalCode),
new Status(status),
new Offense(wantedFor),
pastOffenseSet
);
}

Expand All @@ -61,7 +64,7 @@ public CommandResult execute() {
try {
addressBook.addPerson(toAdd);
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
} catch (UniquePersonList.DuplicatePersonException dpe) {
} catch (UniquePersonList.DuplicateNricException dpe) {
return new CommandResult(MESSAGE_DUPLICATE_PERSON);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/seedu/addressbook/commands/DeleteCommand.java
Expand Up @@ -13,9 +13,9 @@ public class DeleteCommand extends Command {
public static final String COMMAND_WORD = "delete";

public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n"
+ "Deletes the person identified by the index number used in the last person listing.\n\t"
+ "Parameters: INDEX\n\t"
+ "Example: " + COMMAND_WORD + " 1";
+ "Deletes the person by nric.\n\t"
+ "Parameters: NRIC\n\t"
+ "Example: " + COMMAND_WORD + " s1234567";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";

Expand Down
2 changes: 1 addition & 1 deletion src/seedu/addressbook/commands/HelpCommand.java
Expand Up @@ -16,7 +16,7 @@ public class HelpCommand extends Command {
+ "\n" + ClearCommand.MESSAGE_USAGE
+ "\n" + FindCommand.MESSAGE_USAGE
+ "\n" + ListCommand.MESSAGE_USAGE
+ "\n" + ViewCommand.MESSAGE_USAGE
//+ "\n" + ViewCommand.MESSAGE_USAGE
+ "\n" + ViewAllCommand.MESSAGE_USAGE
+ "\n" + HelpCommand.MESSAGE_USAGE
+ "\n" + ExitCommand.MESSAGE_USAGE;
Expand Down
4 changes: 3 additions & 1 deletion src/seedu/addressbook/commands/ViewCommand.java
Expand Up @@ -8,6 +8,7 @@
* Shows details of the person identified using the last displayed index.
* Private contact details are not shown.
*/
/**
public class ViewCommand extends Command {

public static final String COMMAND_WORD = "view";
Expand All @@ -32,10 +33,11 @@ public CommandResult execute() {
if (!addressBook.containsPerson(target)) {
return new CommandResult(Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK);
}
return new CommandResult(String.format(MESSAGE_VIEW_PERSON_DETAILS, target.getAsTextHidePrivate()));
return new CommandResult(String.format(MESSAGE_VIEW_PERSON_DETAILS, target.getAsTextShowAll()));
} catch (IndexOutOfBoundsException ie) {
return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}
}

}
*/
2 changes: 1 addition & 1 deletion src/seedu/addressbook/data/AddressBook.java
Expand Up @@ -38,7 +38,7 @@ public AddressBook(UniquePersonList persons) {
*
* @throws DuplicatePersonException if an equivalent person already exists.
*/
public void addPerson(Person toAdd) throws DuplicatePersonException {
public void addPerson(Person toAdd) throws UniquePersonList.DuplicateNricException {
allPersons.add(toAdd);
}

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

import seedu.addressbook.Location;



import java.sql.Timestamp;
import java.text.SimpleDateFormat;


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 PatrolID attendingPO;
public String caseMessage;
public static Location gpsCoordinates;
public static Timestamp caseTimeStamp;
public static String caseTimeStampFormatted;
private static final SimpleDateFormat timestampFormatter = new SimpleDateFormat("dd.MM.yyyy.HH.mm.ss");


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

public Case(){
this.attendingPO = null;
this.caseMessage = "none";
this.gpsCoordinates = null;
this.caseTimeStamp = null;
}
public Case(PatrolID patrolIDNo, String message, Location location, Timestamp dateTime){

this.attendingPO = patrolIDNo;
this.caseMessage = message;
this.gpsCoordinates = location;
this.caseTimeStampFormatted = timestampFormatter.format(dateTime);
this.value = patrolIDNo.patrolID + SPACE + caseMessage + SPACE + Double.toString(location.getLongitude()) + SPACE +
Double.toString(location.getLatitude()) + SPACE + timestampFormatter.format(dateTime);

}

public String PrintCase() {return value;}

public String getAttendingPO(){return attendingPO.patrolID;}

public String getCaseMessage() {return caseMessage;}

public String getGpsCoorinates() {return Double.toString(gpsCoordinates.getLongitude()) + SPACE + Double.toString(gpsCoordinates.getLatitude());}

public Timestamp getCaseTimeStamp() {return caseTimeStamp;}

public String getCaseTimeStampFormatted() {return caseTimeStampFormatted;}

/*public static void main(String[] args) {
Location location = new Location(-6.206968,106.751365);
Location origin = new Location(-6.189482, 106.733902);
PatrolID id = new PatrolID(5);
String msg = "Fire";
Timestamp now = new Timestamp(System.currentTimeMillis());
Case c = new Case(id,msg,location,now);
System.out.print(c.PrintCase());


}*/

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

import seedu.addressbook.data.exception.IllegalValueException;

/**
* Represents a Patrol resource's ID in EX-SI-53.
* Guarantees: immutable
*/

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){

this.ID = identification;
this.patrolID = PATROL_ID_PREFIX + Integer.toString(identification);
}

public String getPatrolID() {return patrolID;}
/**
* 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();
}

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


import java.util.Objects;

/**
* Represents a Patrol Resource in the system.
* Guarantees: details are present and not null, field values are validated.
*/
public class PatrolResource implements ReadOnlyPatrolResource {
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.getCurrentState().equals(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'
return new Case(); //dummy line
}

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

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

//@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,41 @@
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 getAsTextShowAll() {
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();
}
}