forked from nus-cs2103-AY2425S1/tp
-
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
28 changed files
with
439 additions
and
102 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NEW_REMARK; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TIER; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
||
|
@@ -30,6 +31,7 @@ | |
import seedu.address.model.person.Person; | ||
import seedu.address.model.person.Phone; | ||
import seedu.address.model.person.Remark; | ||
import seedu.address.model.status.Status; | ||
import seedu.address.model.tier.Tier; | ||
|
||
/** | ||
|
@@ -52,6 +54,7 @@ public class EditCommand extends Command { | |
+ "[" + PREFIX_TIER + "TIER]...\n" | ||
+ "[" + PREFIX_NEW_REMARK + "NEW REMARK] " | ||
+ "[" + PREFIX_APPEND_REMARK + "ADD-ON TO EXISTING REMARK] " | ||
+ "[" + PREFIX_STATUS + "STATUS] " | ||
+ "Example: " + COMMAND_WORD + " 1 " | ||
+ PREFIX_PHONE + "91234567 " | ||
+ PREFIX_EMAIL + "[email protected]"; | ||
|
@@ -109,16 +112,17 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript | |
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); | ||
Job updatedJob = editPersonDescriptor.getJob().orElse(personToEdit.getJob()); | ||
Income updatedIncome = editPersonDescriptor.getIncome().orElse(personToEdit.getIncome()); | ||
Tier updatedTier = editPersonDescriptor.getTiers().orElse(personToEdit.getTier()); | ||
Tier updatedTier = editPersonDescriptor.getTier().orElse(personToEdit.getTier()); | ||
Remark updatedRemark; | ||
if (editPersonDescriptor.getAppendedRemark().isPresent()) { | ||
updatedRemark = Remark.combineRemarks(personToEdit.getRemark(), | ||
editPersonDescriptor.getAppendedRemark().get()); | ||
} else { | ||
updatedRemark = editPersonDescriptor.getNewRemark().orElse(personToEdit.getRemark()); | ||
} | ||
Status updatedStatus = editPersonDescriptor.getStatus().orElse(personToEdit.getStatus()); | ||
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedJob, updatedIncome, | ||
updatedTier, updatedRemark); | ||
updatedTier, updatedRemark, updatedStatus); | ||
} | ||
|
||
@Override | ||
|
@@ -159,6 +163,7 @@ public static class EditPersonDescriptor { | |
private Tier tier; | ||
private Remark remark; | ||
private Remark appendedRemark; | ||
private Status status; | ||
public EditPersonDescriptor() {} | ||
|
||
/** | ||
|
@@ -175,13 +180,15 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { | |
setTier(toCopy.tier); | ||
setNewRemark(toCopy.remark); | ||
setAppendedRemark(toCopy.appendedRemark); | ||
setStatus(toCopy.status); | ||
} | ||
|
||
/** | ||
* Returns true if at least one field is edited. | ||
*/ | ||
public boolean isAnyFieldEdited() { | ||
return CollectionUtil.isAnyNonNull(name, phone, email, address, job, income, tier, remark, appendedRemark); | ||
return CollectionUtil.isAnyNonNull(name, phone, email, address, job, income, tier, remark, appendedRemark, | ||
status); | ||
} | ||
|
||
public void setName(Name name) { | ||
|
@@ -235,16 +242,16 @@ public Optional<Income> getIncome() { | |
* Sets {@code tags} to this object's {@code tags}. | ||
* A defensive copy of {@code tags} is used internally. | ||
*/ | ||
public void setTier(Tier tiers) { | ||
this.tier = tiers; | ||
public void setTier(Tier tier) { | ||
this.tier = tier; | ||
} | ||
|
||
/** | ||
* Returns an unmodifiable tier, which throws {@code UnsupportedOperationException} | ||
* if modification is attempted. | ||
* Returns {@code Optional#empty()} if {@code tags} is null. | ||
*/ | ||
public Optional<Tier> getTiers() { | ||
public Optional<Tier> getTier() { | ||
return (tier != null) ? Optional.of(tier) : Optional.empty(); | ||
} | ||
|
||
|
@@ -263,6 +270,13 @@ public void setAppendedRemark(Remark remark) { | |
public Optional<Remark> getAppendedRemark() { | ||
return Optional.ofNullable(appendedRemark); | ||
} | ||
public void setStatus(Status status) { | ||
this.status = status; | ||
} | ||
|
||
public Optional<Status> getStatus() { | ||
return Optional.ofNullable(this.status); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
|
@@ -284,7 +298,8 @@ public boolean equals(Object other) { | |
&& Objects.equals(income, otherEditPersonDescriptor.income) | ||
&& Objects.equals(tier, otherEditPersonDescriptor.tier) | ||
&& Objects.equals(remark, otherEditPersonDescriptor.remark) | ||
&& Objects.equals(appendedRemark, otherEditPersonDescriptor.appendedRemark); | ||
&& Objects.equals(appendedRemark, otherEditPersonDescriptor.appendedRemark) | ||
&& Objects.equals(status, otherEditPersonDescriptor.status); | ||
} | ||
|
||
@Override | ||
|
@@ -298,6 +313,7 @@ public String toString() { | |
.add("income", income) | ||
.add("tier", tier) | ||
.add("remark", remark) | ||
.add("status", status) | ||
.toString(); | ||
} | ||
} | ||
|
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
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
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
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
Oops, something went wrong.