From 9ebbefd4e8490e811de544e34d06237ae3a38440 Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Thu, 13 Oct 2022 09:38:29 +0800 Subject: [PATCH 01/11] Add DeleteGroupCommand --- .../address/logic/commands/DeleteCommand.java | 2 +- .../logic/commands/DeleteGroupCommand.java | 50 +++++++++++++++++++ .../logic/commands/groups/GroupCommand.java | 47 +++++++++++++++++ .../logic/parser/AddressBookParser.java | 3 ++ .../parser/DeleteGroupCommandParser.java | 29 +++++++++++ 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/main/java/seedu/address/logic/commands/DeleteGroupCommand.java create mode 100644 src/main/java/seedu/address/logic/commands/groups/GroupCommand.java create mode 100644 src/main/java/seedu/address/logic/parser/DeleteGroupCommandParser.java diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 02fd256acba..8a11154a247 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -24,7 +24,7 @@ public class DeleteCommand extends Command { public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s"; - private final Index targetIndex; + final Index targetIndex; public DeleteCommand(Index targetIndex) { this.targetIndex = targetIndex; diff --git a/src/main/java/seedu/address/logic/commands/DeleteGroupCommand.java b/src/main/java/seedu/address/logic/commands/DeleteGroupCommand.java new file mode 100644 index 00000000000..5e2bf1d1e47 --- /dev/null +++ b/src/main/java/seedu/address/logic/commands/DeleteGroupCommand.java @@ -0,0 +1,50 @@ +package seedu.address.logic.commands; + +import seedu.address.commons.core.Messages; +import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.group.Group; + +import java.util.List; + +import static java.util.Objects.requireNonNull; + +public class DeleteGroupCommand extends Command { + + public static final String COMMAND_WORD = "rmgroup"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + + ": Deletes the group identified by the index number used in the displayed group list.\n" + + "Parameters: INDEX (must be a positive integer)\n" + + "Example: " + COMMAND_WORD + " 1"; + + public static final String MESSAGE_DELETE_GROUP_SUCCESS = "Deleted Group: %1$s"; + + private final Index targetIndex; + + public DeleteGroupCommand(Index targetIndex) { + this.targetIndex = targetIndex; + } + + @Override + public CommandResult execute(Model model) throws CommandException { + requireNonNull(model); + List lastShownList = model.getFilteredTeamList(); + + if (targetIndex.getZeroBased() >= lastShownList.size()) { + throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + } + + Group groupToDelete = lastShownList.get(targetIndex.getZeroBased()); + model.deleteTeam(groupToDelete); + return new CommandResult(String.format(MESSAGE_DELETE_GROUP_SUCCESS, groupToDelete)); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof DeleteCommand // instanceof handles nulls + && targetIndex.equals(((DeleteCommand) other).targetIndex)); // state check + } +} diff --git a/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java b/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java new file mode 100644 index 00000000000..de3ad462ead --- /dev/null +++ b/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java @@ -0,0 +1,47 @@ +package seedu.address.logic.commands.groups; + +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.group.Group; + +import static java.util.Objects.requireNonNull; + +/** + * Add a team to the address book. + */ +public class GroupCommand extends Command { + public static final String COMMAND_WORD = "team"; + + public static final String MESSAGE_SUCCESS = "New team added: %1$s!"; + public static final String MESSAGE_DUPLICATE_TEAM = "This team already exists in the address book"; + + private final Group toAdd; + /** + * Creates an AddCommand to add the specified {@code Person} + */ + public GroupCommand(Group team) { + requireNonNull(team); + toAdd = team; + } + + @Override + public CommandResult execute(Model model) throws CommandException { + requireNonNull(model); + + if (model.hasTeam(toAdd)) { + throw new CommandException(MESSAGE_DUPLICATE_TEAM); + } + + model.addTeam(toAdd); + return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof GroupCommand // instanceof handles nulls + && toAdd.equals(((GroupCommand) other).toAdd)); + } +} diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 0909692e55b..600f60fc198 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -9,6 +9,7 @@ import seedu.address.logic.commands.AddCommand; import seedu.address.logic.commands.AddGroupCommand; import seedu.address.logic.commands.ChangeGroupCommand; +import seedu.address.logic.commands.DeleteGroupCommand; import seedu.address.logic.commands.ClearCommand; import seedu.address.logic.commands.Command; import seedu.address.logic.commands.DeleteCommand; @@ -76,6 +77,8 @@ public Command parseCommand(String userInput) throws ParseException { case ChangeGroupCommand.COMMAND_WORD: return new ChangeGroupCommandParser().parse(arguments); + case DeleteGroupCommand.COMMAND_WORD: + return new DeleteGroupCommandParser().parse(arguments); default: throw new ParseException(MESSAGE_UNKNOWN_COMMAND); } diff --git a/src/main/java/seedu/address/logic/parser/DeleteGroupCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteGroupCommandParser.java new file mode 100644 index 00000000000..3f2c7e9dd08 --- /dev/null +++ b/src/main/java/seedu/address/logic/parser/DeleteGroupCommandParser.java @@ -0,0 +1,29 @@ +package seedu.address.logic.parser; + +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; + +import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.DeleteGroupCommand; +import seedu.address.logic.parser.exceptions.ParseException; + +/** + * Parses input arguments and creates a new DeleteGroupCommand object + */ +public class DeleteGroupCommandParser implements Parser { + + /** + * 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 + */ + @Override + public DeleteGroupCommand parse(String args) throws ParseException { + try { + Index index = ParserUtil.parseIndex(args); + return new DeleteGroupCommand(index); + } catch (ParseException pe) { + throw new ParseException( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteGroupCommand.MESSAGE_USAGE), pe); + } + } +} From 744114c4f5bb44bff280bb00f9aab504d497927d Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Mon, 17 Oct 2022 11:29:49 +0800 Subject: [PATCH 02/11] Add DeleteGroupCommand in unused folder --- unused/DeleteGroupCommand.java | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 unused/DeleteGroupCommand.java diff --git a/unused/DeleteGroupCommand.java b/unused/DeleteGroupCommand.java new file mode 100644 index 00000000000..38c78bf8314 --- /dev/null +++ b/unused/DeleteGroupCommand.java @@ -0,0 +1,50 @@ +package seedu.address.logic.commands; + +import seedu.address.commons.core.Messages; +import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.group.Group; + +import java.util.List; + +import static java.util.Objects.requireNonNull; + +public class DeleteGroupCommand extends Command { + + public static final String COMMAND_WORD = "rmgroup"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + + ": Deletes the group identified by the index number used in the displayed group list.\n" + + "Parameters: INDEX (must be a positive integer)\n" + + "Example: " + COMMAND_WORD + " 1"; + + public static final String MESSAGE_DELETE_GROUP_SUCCESS = "Deleted Group: %1$s"; + + private final Index targetIndex; + + public DeleteGroupCommand(Index targetIndex) { + this.targetIndex = targetIndex; + } + + @Override + public CommandResult execute(Model model) throws CommandException { + requireNonNull(model); + List lastShownList = model.getFilteredTeamList(); + + if (targetIndex.getZeroBased() >= lastShownList.size()) { + throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + } + + Group groupToDelete = lastShownList.get(targetIndex.getZeroBased()); + model.deleteTeam(groupToDelete); + return new CommandResult(String.format(MESSAGE_DELETE_GROUP_SUCCESS, groupToDelete)); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof DeleteCommand // instanceof handles nulls + && targetIndex.equals(((DeleteCommand) other).targetIndex)); // state check + } +} \ No newline at end of file From 7659c05740e7aa7c59b1122d143c532e80026e64 Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Mon, 17 Oct 2022 16:09:12 +0800 Subject: [PATCH 03/11] Edit AddressBookParser --- .../java/seedu/address/logic/parser/AddressBookParser.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 596512e2b6a..cdb62bd1a6c 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -110,9 +110,7 @@ public Command parseCommand(String userInput) throws ParseException { case RemoveUserFromTeamCommand.COMMAND_WORD: return new RemoveUserFromTeamCommandParser().parse(arguments); - - case DeleteGroupCommand.COMMAND_WORD: - return new DeleteGroupCommandParser().parse(arguments); + default: throw new ParseException(MESSAGE_UNKNOWN_COMMAND); } From 21c1ef7f6c4acabeaa166d9a95be0a6dc823d119 Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Mon, 17 Oct 2022 17:00:55 +0800 Subject: [PATCH 04/11] Fix bug in AddressBookParser --- .../java/seedu/address/logic/parser/AddressBookParser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index cdb62bd1a6c..8ba4bc6c33f 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -110,10 +110,11 @@ public Command parseCommand(String userInput) throws ParseException { case RemoveUserFromTeamCommand.COMMAND_WORD: return new RemoveUserFromTeamCommandParser().parse(arguments); - + default: throw new ParseException(MESSAGE_UNKNOWN_COMMAND); } } } + From 12102f50ce37e4cc869aa41cf8705725a3ba1b3a Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Mon, 17 Oct 2022 17:02:37 +0800 Subject: [PATCH 05/11] no message --- .../logic/commands/DeleteGroupCommand.java | 50 ------------------- .../parser/DeleteGroupCommandParser.java | 29 ----------- 2 files changed, 79 deletions(-) delete mode 100644 src/main/java/seedu/address/logic/commands/DeleteGroupCommand.java delete mode 100644 src/main/java/seedu/address/logic/parser/DeleteGroupCommandParser.java diff --git a/src/main/java/seedu/address/logic/commands/DeleteGroupCommand.java b/src/main/java/seedu/address/logic/commands/DeleteGroupCommand.java deleted file mode 100644 index 5e2bf1d1e47..00000000000 --- a/src/main/java/seedu/address/logic/commands/DeleteGroupCommand.java +++ /dev/null @@ -1,50 +0,0 @@ -package seedu.address.logic.commands; - -import seedu.address.commons.core.Messages; -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; -import seedu.address.model.group.Group; - -import java.util.List; - -import static java.util.Objects.requireNonNull; - -public class DeleteGroupCommand extends Command { - - public static final String COMMAND_WORD = "rmgroup"; - - public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Deletes the group identified by the index number used in the displayed group list.\n" - + "Parameters: INDEX (must be a positive integer)\n" - + "Example: " + COMMAND_WORD + " 1"; - - public static final String MESSAGE_DELETE_GROUP_SUCCESS = "Deleted Group: %1$s"; - - private final Index targetIndex; - - public DeleteGroupCommand(Index targetIndex) { - this.targetIndex = targetIndex; - } - - @Override - public CommandResult execute(Model model) throws CommandException { - requireNonNull(model); - List lastShownList = model.getFilteredTeamList(); - - if (targetIndex.getZeroBased() >= lastShownList.size()) { - throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); - } - - Group groupToDelete = lastShownList.get(targetIndex.getZeroBased()); - model.deleteTeam(groupToDelete); - return new CommandResult(String.format(MESSAGE_DELETE_GROUP_SUCCESS, groupToDelete)); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof DeleteCommand // instanceof handles nulls - && targetIndex.equals(((DeleteCommand) other).targetIndex)); // state check - } -} diff --git a/src/main/java/seedu/address/logic/parser/DeleteGroupCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteGroupCommandParser.java deleted file mode 100644 index 3f2c7e9dd08..00000000000 --- a/src/main/java/seedu/address/logic/parser/DeleteGroupCommandParser.java +++ /dev/null @@ -1,29 +0,0 @@ -package seedu.address.logic.parser; - -import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; - -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.DeleteGroupCommand; -import seedu.address.logic.parser.exceptions.ParseException; - -/** - * Parses input arguments and creates a new DeleteGroupCommand object - */ -public class DeleteGroupCommandParser implements Parser { - - /** - * 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 - */ - @Override - public DeleteGroupCommand parse(String args) throws ParseException { - try { - Index index = ParserUtil.parseIndex(args); - return new DeleteGroupCommand(index); - } catch (ParseException pe) { - throw new ParseException( - String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteGroupCommand.MESSAGE_USAGE), pe); - } - } -} From 343c52432355c65a629d6445bbefa911db4d72f9 Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Sat, 22 Oct 2022 15:22:54 +0800 Subject: [PATCH 06/11] Update Developer Guide with implementation of Tasks in Model folder. --- docs/DeveloperGuide.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index a9a7dd81cee..5f1fce48402 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -131,6 +131,22 @@ How the parsing works: * When called upon to parse a user command, the `AddressBookParser` class creates an `XYZCommandParser` (`XYZ` is a placeholder for the specific command name e.g., `AddCommandParser`) which uses the other classes shown above to parse the user command and create a `XYZCommand` object (e.g., `AddCommand`) which the `AddressBookParser` returns back as a `Command` object. * All `XYZCommandParser` classes (e.g., `AddCommandParser`, `DeleteCommandParser`, ...) inherit from the `Parser` interface so that they can be treated similarly where possible e.g, during testing. +#### Tasks + +Commands for tasks (e.g., `AddTaskCommand`, `MarkTaskCommand`, ...) follow a similar sequence of interactions within +the `Logic` component as the other commands described above. + +However, during execution, tasks commands may update the context of the current tasks of a team. To understand tasks better, +Tasks are analogous to folders in a basic file system, which can contain other folders (`Team`), or other +files (`Person` or `Task`). + +The Sequence Diagram below shows the interaction between `Logic` and `Model` components when `execute("at ..")` is called. + +[insert Sequence Diagram] + +This way of implementation of maintains abstraction of details of the `Logic` component, in the `Model` component. + + ### Model component **API** : [`Model.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/model/Model.java) From d315eb22d75afbbe8e8402fb4541bebbb6a194dc Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Sat, 22 Oct 2022 15:27:59 +0800 Subject: [PATCH 07/11] Fix bugs --- unused/DeleteGroupCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unused/DeleteGroupCommand.java b/unused/DeleteGroupCommand.java index 38c78bf8314..5e2bf1d1e47 100644 --- a/unused/DeleteGroupCommand.java +++ b/unused/DeleteGroupCommand.java @@ -47,4 +47,4 @@ public boolean equals(Object other) { || (other instanceof DeleteCommand // instanceof handles nulls && targetIndex.equals(((DeleteCommand) other).targetIndex)); // state check } -} \ No newline at end of file +} From 9d510826a60d9e191fc6fdedbf4ea417281f65a3 Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Sat, 22 Oct 2022 15:32:20 +0800 Subject: [PATCH 08/11] no message --- .../seedu/address/logic/commands/groups/GroupCommand.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java b/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java index de3ad462ead..4db7ba2b91a 100644 --- a/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java +++ b/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java @@ -1,13 +1,11 @@ package seedu.address.logic.commands.groups; - +import static java.util.Objects.requireNonNull; import seedu.address.logic.commands.Command; import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.group.Group; -import static java.util.Objects.requireNonNull; - /** * Add a team to the address book. */ From 90f8c65eef426f901b597b227ac295f15d008c1a Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Sat, 22 Oct 2022 15:34:12 +0800 Subject: [PATCH 09/11] no message --- .../java/seedu/address/logic/commands/groups/GroupCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java b/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java index 4db7ba2b91a..51b0be5021e 100644 --- a/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java +++ b/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java @@ -1,4 +1,5 @@ package seedu.address.logic.commands.groups; + import static java.util.Objects.requireNonNull; import seedu.address.logic.commands.Command; import seedu.address.logic.commands.CommandResult; From c71b7a8f95ed9646985bf6254df2d77a34e30b81 Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Sat, 22 Oct 2022 15:35:50 +0800 Subject: [PATCH 10/11] no message --- .../java/seedu/address/logic/commands/groups/GroupCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java b/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java index 51b0be5021e..5960a810863 100644 --- a/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java +++ b/src/main/java/seedu/address/logic/commands/groups/GroupCommand.java @@ -1,6 +1,7 @@ package seedu.address.logic.commands.groups; import static java.util.Objects.requireNonNull; + import seedu.address.logic.commands.Command; import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; From da53209413628a74156de38003371822fc23e735 Mon Sep 17 00:00:00 2001 From: mohamedsaf1 Date: Sat, 22 Oct 2022 15:46:19 +0800 Subject: [PATCH 11/11] Update Teams implementation on Developer Guide --- docs/DeveloperGuide.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 5f1fce48402..dcedc66bbb5 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -137,8 +137,9 @@ Commands for tasks (e.g., `AddTaskCommand`, `MarkTaskCommand`, ...) follow a sim the `Logic` component as the other commands described above. However, during execution, tasks commands may update the context of the current tasks of a team. To understand tasks better, -Tasks are analogous to folders in a basic file system, which can contain other folders (`Team`), or other -files (`Person` or `Task`). +it should be understood that Tasks are an attribute of a Teams object, which is used to indicate if a tasks is done (also known as marked), +or not (also known as unmarked). + The Sequence Diagram below shows the interaction between `Logic` and `Model` components when `execute("at ..")` is called.