forked from nus-cs2103-AY1819S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nus-cs2103-AY1819S1#65 from dioptrique/AddCommand
Add command, Date and UUID
- Loading branch information
Showing
98 changed files
with
1,259 additions
and
842 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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/seedu/address/commons/exceptions/DataConversionException.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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PRICE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
|
@@ -23,17 +23,17 @@ public class AddCommand extends Command { | |
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a wish to the address book. " | ||
+ "Parameters: " | ||
+ PREFIX_NAME + "NAME " | ||
+ PREFIX_PRICE + "PHONE " | ||
+ PREFIX_EMAIL + "EMAIL " | ||
+ PREFIX_URL + "ADDRESS " | ||
+ PREFIX_PRICE + "PRICE " | ||
+ PREFIX_DATE + "DATE " | ||
+ "[" + PREFIX_URL + "URL] " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + "John Doe " | ||
+ PREFIX_PRICE + "60.50 " | ||
+ PREFIX_EMAIL + "[email protected] " | ||
+ PREFIX_NAME + "iPad 10 " | ||
+ PREFIX_PRICE + "6080.50 " | ||
+ PREFIX_DATE + "20/11/2021 " | ||
+ PREFIX_URL + "https://www.amazon.com/gp/product/B07D998212 " | ||
+ PREFIX_TAG + "friends " | ||
+ PREFIX_TAG + "owesMoney"; | ||
+ PREFIX_TAG + "electronics " | ||
+ PREFIX_TAG + "personal "; | ||
|
||
public static final String MESSAGE_SUCCESS = "New wish added: %1$s"; | ||
public static final String MESSAGE_DUPLICATE_WISH = "This wish already exists in the address book"; | ||
|
@@ -67,4 +67,14 @@ public boolean equals(Object other) { | |
|| (other instanceof AddCommand // instanceof handles nulls | ||
&& toAdd.equals(((AddCommand) other).toAdd)); | ||
} | ||
|
||
/** | ||
* A weaker notion of equality between {@code AddCommand}. | ||
*/ | ||
public boolean isSameAs(AddCommand other) { | ||
return other == this | ||
|| toAdd.getName().equals(other.toAdd.getName()) | ||
&& toAdd.getPrice().equals(other.toAdd.getPrice()) | ||
&& toAdd.getDate().equals(other.toAdd.getDate()); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PRICE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
|
@@ -10,10 +10,10 @@ | |
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
import seedu.address.commons.core.Messages; | ||
import seedu.address.commons.core.index.Index; | ||
|
@@ -23,7 +23,7 @@ | |
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.tag.Tag; | ||
import seedu.address.model.wish.Email; | ||
import seedu.address.model.wish.Date; | ||
import seedu.address.model.wish.Name; | ||
import seedu.address.model.wish.Price; | ||
import seedu.address.model.wish.Remark; | ||
|
@@ -45,12 +45,12 @@ public class EditCommand extends Command { | |
+ "Parameters: INDEX (must be a positive integer) " | ||
+ "[" + PREFIX_NAME + "NAME] " | ||
+ "[" + PREFIX_PRICE + "PHONE] " | ||
+ "[" + PREFIX_EMAIL + "EMAIL] " | ||
+ "[" + PREFIX_DATE + "EMAIL] " | ||
+ "[" + PREFIX_URL + "URL] " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " 1 " | ||
+ PREFIX_PRICE + "60.60 " | ||
+ PREFIX_EMAIL + "[email protected]"; | ||
+ PREFIX_DATE + "[email protected]"; | ||
|
||
public static final String MESSAGE_EDIT_WISH_SUCCESS = "Edited Wish: %1$s"; | ||
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; | ||
|
@@ -74,7 +74,7 @@ public EditCommand(Index index, EditWishDescriptor editWishDescriptor) { | |
@Override | ||
public CommandResult execute(Model model, CommandHistory history) throws CommandException { | ||
requireNonNull(model); | ||
List<Wish> lastShownList = model.getFilteredWishList(); | ||
List<Wish> lastShownList = model.getFilteredSortedWishList(); | ||
|
||
if (index.getZeroBased() >= lastShownList.size()) { | ||
throw new CommandException(Messages.MESSAGE_INVALID_WISH_DISPLAYED_INDEX); | ||
|
@@ -102,16 +102,15 @@ private static Wish createEditedWish(Wish wishToEdit, EditWishDescriptor editWis | |
|
||
Name updatedName = editWishDescriptor.getName().orElse(wishToEdit.getName()); | ||
Price updatedPrice = editWishDescriptor.getPrice().orElse(wishToEdit.getPrice()); | ||
Email updatedEmail = editWishDescriptor.getEmail().orElse(wishToEdit.getEmail()); | ||
Date updatedDate = editWishDescriptor.getDate().orElse(wishToEdit.getDate()); | ||
Url updatedUrl = editWishDescriptor.getUrl().orElse(wishToEdit.getUrl()); | ||
SavedAmount savedAmount = wishToEdit.getSavedAmount(); // edit command does not allow editing remarks | ||
Remark remark = wishToEdit.getRemark(); // cannot modify remark with edit command | ||
Set<Tag> updatedTags = editWishDescriptor.getTags().orElse(wishToEdit.getTags()); | ||
LinkedList<Wish> transactions = wishToEdit.getTransactions(); // no editing of transactions | ||
UUID originalUuid = wishToEdit.getId(); | ||
|
||
return new Wish(updatedName, updatedPrice, updatedEmail, updatedUrl, savedAmount, remark, | ||
updatedTags, | ||
transactions); | ||
return new Wish(updatedName, updatedPrice, updatedDate, updatedUrl, | ||
savedAmount, remark, updatedTags, originalUuid); | ||
} | ||
|
||
@Override | ||
|
@@ -139,7 +138,7 @@ public boolean equals(Object other) { | |
public static class EditWishDescriptor { | ||
private Name name; | ||
private Price price; | ||
private Email email; | ||
private Date date; | ||
private Url url; | ||
private Set<Tag> tags; | ||
|
||
|
@@ -152,7 +151,7 @@ public EditWishDescriptor() {} | |
public EditWishDescriptor(EditWishDescriptor toCopy) { | ||
setName(toCopy.name); | ||
setPrice(toCopy.price); | ||
setEmail(toCopy.email); | ||
setDate(toCopy.date); | ||
setUrl(toCopy.url); | ||
setTags(toCopy.tags); | ||
} | ||
|
@@ -161,7 +160,7 @@ public EditWishDescriptor(EditWishDescriptor toCopy) { | |
* Returns true if at least one field is edited. | ||
*/ | ||
public boolean isAnyFieldEdited() { | ||
return CollectionUtil.isAnyNonNull(name, price, email, url, tags); | ||
return CollectionUtil.isAnyNonNull(name, price, date, url, tags); | ||
} | ||
|
||
public void setName(Name name) { | ||
|
@@ -180,12 +179,12 @@ public Optional<Price> getPrice() { | |
return Optional.ofNullable(price); | ||
} | ||
|
||
public void setEmail(Email email) { | ||
this.email = email; | ||
public void setDate(Date date) { | ||
this.date = date; | ||
} | ||
|
||
public Optional<Email> getEmail() { | ||
return Optional.ofNullable(email); | ||
public Optional<Date> getDate() { | ||
return Optional.ofNullable(date); | ||
} | ||
|
||
public void setUrl(Url url) { | ||
|
@@ -230,7 +229,7 @@ public boolean equals(Object other) { | |
|
||
return getName().equals(e.getName()) | ||
&& getPrice().equals(e.getPrice()) | ||
&& getEmail().equals(e.getEmail()) | ||
&& getDate().equals(e.getDate()) | ||
&& getUrl().equals(e.getUrl()) | ||
&& getTags().equals(e.getTags()); | ||
} | ||
|
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.