Skip to content

Commit

Permalink
Merge pull request #50 from mohamedsaf1/branch-devguide
Browse files Browse the repository at this point in the history
Update Teams implementation in Developer Guide
  • Loading branch information
jasonchristopher21 authored Oct 22, 2022
2 parents 6dfda2e + da53209 commit de520d0
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 1 deletion.
17 changes: 17 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ 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,
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.

[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/AY2223S1-CS2103T-T11-1/tp/blob/master/src/main/java/seedu/address/model/Model.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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;

/**
* 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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ public Command parseCommand(String userInput) throws ParseException {
}

}

50 changes: 50 additions & 0 deletions unused/DeleteGroupCommand.java
Original file line number Diff line number Diff line change
@@ -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<Group> 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
}
}

0 comments on commit de520d0

Please sign in to comment.