Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlimdx committed Apr 12, 2024
2 parents d1d3334 + 599f575 commit 06ad182
Show file tree
Hide file tree
Showing 24 changed files with 291 additions and 175 deletions.
333 changes: 182 additions & 151 deletions docs/DeveloperGuide.md

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions docs/diagrams/AddActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@startuml
'https://plantuml.com/activity-diagram-beta

start
:User enters add command;
:LogicManager executes user input;
:AddressBookParser parses add command;
:AddCommandParser parses the arguments provided in add command;

if () then ([else])
:Outputs error message;
stop
else ([valid arguments])
:AddCommand object is created;
if () then ([person already exists])
:Outputs error message;
else ([else])
:AddCommand object is passed to LogicManager;
:New patient added into Nursing Address Book;
endif
stop

@enduml
18 changes: 18 additions & 0 deletions docs/diagrams/DeleteActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@startuml
'https://plantuml.com/activity-diagram-beta

start
: User enters delete command;
: LogicManager executes user input;
: AddressBookParser parses delete command;
: DeleteCommandParser parses the arguments provided in add command;
if() then ([valid index])
: AddressBookManager deletes the contact;
else ([else])
: Outputs an error message;
endif


stop

@enduml
File renamed without changes.
Binary file added docs/images/AddActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/DeleteActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/FindActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/FindAvtivityDiagram.png
Binary file not shown.
9 changes: 5 additions & 4 deletions src/main/java/seedu/address/commons/util/DateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class DateUtil {

public static final String MESSAGE_CONSTRAINTS_FORMAT = "%1$s takes in a date of format dd/MM/yyyy";
public static final String MESSAGE_CONSTRAINTS_FUTURE_OCCURRENCE = "%1$s should not be later than current date";
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");

private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy");

/**
* Returns true if a given string is a valid date.
Expand All @@ -20,7 +21,7 @@ public class DateUtil {
*/
public static boolean isValidDate(String value) {
try {
LocalDate date = LocalDate.parse(value, formatter);
LocalDate date = LocalDate.parse(value, FORMATTER);
return true;
} catch (DateTimeParseException e) {
return false;
Expand All @@ -33,7 +34,7 @@ public static boolean isValidDate(String value) {
*/
public static boolean isFutureDate(String value) {
if (isValidDate(value)) {
LocalDate date = LocalDate.parse(value, formatter);
LocalDate date = LocalDate.parse(value, FORMATTER);
return date.isAfter(LocalDate.now());
}
return false;
Expand All @@ -43,6 +44,6 @@ public static boolean isFutureDate(String value) {
* Returns the formatter for the date.
*/
public static DateTimeFormatter getFormatter() {
return formatter;
return FORMATTER;
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Adds a person to the address book.
*/
public class AddCommand extends Command {

public static final String COMMAND_WORD = "add";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. \n"
+ "Parameters: "
Expand All @@ -39,7 +40,6 @@ public class AddCommand extends Command {
+ PREFIX_REMARK + "Prevent bed sores. "
+ PREFIX_TAG + "FallRisk";
public static final String MESSAGE_SUCCESS = "New patient added: %1$s";

public static final String MESSAGE_DUPLICATE_PERSON = "A patient with this IC already exists in the address book";

private final Person toAdd;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,36 +207,47 @@ public void setTags(Set<Tag> tags) {
public Optional<Set<Tag>> getTags() {
return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty();
}

public void setIc(Ic ic) {
this.ic = ic;
}

public Optional<Ic> getIc() {
return Optional.ofNullable(ic);
}

public void setDob(Dob dob) {
this.dob = dob;
}

public Optional<Dob> getDob() {
return Optional.ofNullable(dob);
}

public void setAdmissionDate(AdmissionDate admissionDate) {
this.admissionDate = admissionDate;
}

public Optional<AdmissionDate> getAdmissionDate() {
return Optional.ofNullable(admissionDate);
}

public void setWard(Ward ward) {
this.ward = ward;
}

public Optional<Ward> getWard() {
return Optional.ofNullable(ward);
}

public void setRemark(Remark remark) {
this.remark = remark;
}

public Optional<Remark> getRemark() {
return Optional.ofNullable(remark);
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ExitCommand extends Command {

@Override
public CommandResult execute(Model model) {

return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/logic/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ListCommand extends Command {

public static final String MESSAGE_SUCCESS = "Listed all persons";
public static final String MESSAGE_SUCCESS_LIST = "Listed all persons with: %1$s";

private final ListKeywordsPredicate predicate;

/**
Expand Down Expand Up @@ -74,7 +75,7 @@ public boolean equals(Object other) {
@Override
public String toString() {
return new ToStringBuilder(this)
.add("predicate", predicate == null ? "null" : predicate)
.add("predicate", (predicate == null) ? "null" : predicate)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AddCommandParser implements Parser<AddCommand> {
/**
* Parses the given {@code String} of arguments in the context of the AddCommand
* and returns an AddCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public AddCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class DeleteCommandParser implements Parser<DeleteCommand> {
/**
* Parses the given {@code String} of arguments in the context of the DeleteCommand
* and returns a DeleteCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public DeleteCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class EditCommandParser implements Parser<EditCommand> {
/**
* Parses the given {@code String} of arguments in the context of the EditCommand
* and returns an EditCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public EditCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class FindCommandParser implements Parser<FindCommand> {
/**
* Parses the given {@code String} of arguments in the context of the FindCommand
* and returns a FindCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public FindCommand parse(String args) throws ParseException {
Expand Down
24 changes: 15 additions & 9 deletions src/main/java/seedu/address/logic/parser/ListCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ public class ListCommandParser implements Parser<ListCommand> {
/**
* Parses the given {@code String} of arguments in the context of the ListCommand
* and returns a ListCommand object for execution.
*
* @param args the arguments to parse.
* @return a ListCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public ListCommand parse(String args) throws ParseException {
String trimmedArgs = args.trim();
// If there are no arguments, return a ListCommand object with no predicate

// If there are no arguments, list all patients
if (trimmedArgs.isEmpty()) {
return new ListCommand(); // return a ListCommand object with no predicate
return new ListCommand();
}

// If there are arguments, parse the arguments and return a ListCommand object with the parsed predicate
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_TAG, PREFIX_WARD);
// If there are arguments, filter patients based on the arguments
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_TAG, PREFIX_WARD);
if (!argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ListCommand.MESSAGE_USAGE));
}
Expand All @@ -39,27 +42,30 @@ public ListCommand parse(String args) throws ParseException {
List<String> tagList = List.of();
if (arePrefixesPresent(argMultimap, PREFIX_TAG)) {
tagList = ParserUtil.parseTagsKeywords(argMultimap.getAllValues(PREFIX_TAG));
assert !tagList.isEmpty();
assert !tagList.isEmpty() : "tagList should not be empty";
}

String ward = "";
if (arePrefixesPresent(argMultimap, PREFIX_WARD)) {
ward = ParserUtil.parseWard(argMultimap.getValue(PREFIX_WARD).orElse(null)).toString();
assert !ward.isEmpty();
assert !ward.isEmpty() : "ward should not be empty";
}

if (ward.isEmpty() && tagList.isEmpty()) { // If there are no valid arguments, throw an exception
if (ward.isEmpty() && tagList.isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ListCommand.MESSAGE_USAGE));
}

assert !tagList.isEmpty() || !ward.isEmpty();
assert !tagList.isEmpty() || !ward.isEmpty() : "at least either tagList or ward must be supplied";

return new ListCommand(new ListKeywordsPredicate(tagList, ward));
}

/**
* Returns true if none of the prefixes contains empty {@code Optional} values in the given
* {@code ArgumentMultimap}.
*
* @param argumentMultimap the {@code ArgumentMultimap} to check for the presence of prefixes.
* @param prefixes the prefixes to check for.
*/
private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) {
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static Ic parseIc(String ic) throws ParseException {
}

/**
* Parses a {@code String admissionDate, Dob dob} into a {@code AdmissionDate}.
* Parses a {@code String admissionDate} into a {@code AdmissionDate}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if the given {@code admissionDate} is invalid.
Expand Down Expand Up @@ -163,7 +163,7 @@ public static Ward parseWard(String ward) throws ParseException {
* Parses a {@code String remark} into a {@code Remark}.
* Leading and trailing whitespaces will be trimmed.
*/
public static Remark parseRemark(String remark) throws ParseException {
public static Remark parseRemark(String remark) {
if (remark == null) {
return new Remark("");
} else {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/logic/parser/Prefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
public class Prefix {
private final String prefix;

/**
* Constructs a Prefix object.
*
* @param prefix A valid prefix.
*/
public Prefix(String prefix) {
this.prefix = prefix;
}

/**
* Returns the prefix string.
*
* @return Prefix string.
*/
public String getPrefix() {
return prefix;
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/seedu/address/model/person/AdmissionDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
*/
public class AdmissionDate extends DateUtil {
public static final String DATE_TYPE = "Admission date";
public static final String MESSAGE_CONSTRAINTS_FORMAT =
String.format(DateUtil.MESSAGE_CONSTRAINTS_FORMAT, DATE_TYPE);
public static final String MESSAGE_CONSTRAINTS_OCCURRENCE =
"Admission date should not be earlier than date of birth or later than current date";
public static final String MESSAGE_CONSTRAINTS_FORMAT = String
.format(DateUtil.MESSAGE_CONSTRAINTS_FORMAT, DATE_TYPE);
public static final String MESSAGE_CONSTRAINTS_OCCURRENCE = String
.format("%1$s should not be earlier than date of birth or later than current date", DATE_TYPE);

private final LocalDate admissionDate;
private final String value;
Expand Down Expand Up @@ -51,6 +51,7 @@ public boolean equals(Object other) {
return true;
}

// instanceof handles nulls
if (!(other instanceof AdmissionDate)) {
return false;
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/seedu/address/model/person/Dob.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public class Dob extends DateUtil {
String.format(DateUtil.MESSAGE_CONSTRAINTS_FORMAT, DATE_TYPE);
public static final String MESSAGE_CONSTRAINTS_FUTURE_OCCURRENCE =
String.format(DateUtil.MESSAGE_CONSTRAINTS_FUTURE_OCCURRENCE, DATE_TYPE);

public static final String MESSAGE_DOB_AFTER_ADMISSION =
"Date of birth should not be later than date of admission.";

private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy");

private final LocalDate dob;
private final String value;

Expand All @@ -34,7 +34,7 @@ public Dob(String value) {
requireNonNull(value);
checkArgument(isValidDate(value), MESSAGE_CONSTRAINTS_FORMAT);
checkArgument(!isFutureDate(value), MESSAGE_CONSTRAINTS_FUTURE_OCCURRENCE);
this.dob = LocalDate.parse(value, formatter);
this.dob = LocalDate.parse(value, FORMATTER);
this.value = value;
}

Expand Down Expand Up @@ -63,6 +63,7 @@ public boolean equals(Object other) {
return true;
}

// instanceof handles nulls
if (!(other instanceof Dob)) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/person/Ic.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public boolean equals(Object other) {
return true;
}

// instanceof handles nulls
if (!(other instanceof Ic)) {
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
* Contains utility methods for populating {@code AddressBook} with sample data.
*/
public class SampleDataUtil {

/**
* Returns an array of sample persons.
*/
public static Person[] getSamplePersons() {
return new Person[]{

Expand All @@ -40,6 +44,9 @@ public static Person[] getSamplePersons() {
};
}

/**
* Returns an address book containing sample persons.
*/
public static ReadOnlyAddressBook getSampleAddressBook() {
AddressBook sampleAb = new AddressBook();
for (Person samplePerson : getSamplePersons()) {
Expand Down

0 comments on commit 06ad182

Please sign in to comment.