Skip to content

Commit

Permalink
Merge branch 'master' into improve-UG-overall
Browse files Browse the repository at this point in the history
  • Loading branch information
belligerentbeagle authored Apr 10, 2024
2 parents 7635849 + 256b5e3 commit 08f6aa5
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 55 deletions.
175 changes: 129 additions & 46 deletions docs/UserGuide.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/_markbind/_macros.nj
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
</box>

{% endmacro %}



{# Keyboard key formatting #}
{% macro keyFormat(name, icon='') %}<span class="badge bg-light text-dark border">{% if icon %}{{ icon }} {% endif %}{{ name | upper }}</span>{% endmacro %}
9 changes: 1 addition & 8 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
import seedu.address.logic.autocomplete.AutoComplete;
import seedu.address.logic.autocomplete.AutoCompleteCommand;
import seedu.address.logic.autocomplete.AutoCompleteResult;
import seedu.address.logic.commands.AddPersonCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.DeletePersonCommand;
import seedu.address.logic.commands.EditPersonCommand;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.AddressBookParser;
import seedu.address.logic.parser.exceptions.ParseException;
Expand Down Expand Up @@ -59,10 +55,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE
CommandResult commandResult = command.execute(model);

// Update the attributes value generation for prefix autocompletion.
if (command instanceof AddPersonCommand
|| command instanceof DeletePersonCommand
|| command instanceof EditPersonCommand
|| command instanceof ClearCommand) {
if (command.isModification()) {
AttributeValueGeneratorManager.updateAddressBook(getAddressBook());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public CommandResult execute(Model model) throws CommandException {
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd)));
}

@Override
public boolean isModification() {
return true;
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/logic/commands/ClearCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ public CommandResult execute(Model model) {
model.setAddressBook(new AddressBook());
return new CommandResult(MESSAGE_SUCCESS);
}

@Override
public boolean isModification() {
return true;
}
}
8 changes: 8 additions & 0 deletions src/main/java/seedu/address/logic/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ public abstract class Command {
*/
public abstract CommandResult execute(Model model) throws CommandException;

/**
* Returns true if the command potentially modifies the model in a way that should be saved to storage.
*
* @return True if the command potentially modifies the model, otherwise false.
*/
public boolean isModification() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public CommandResult execute(Model model) throws CommandException {
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)));
}

@Override
public boolean isModification() {
return true;
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public CommandResult execute(Model model) throws CommandException {
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)));
}

@Override
public boolean isModification() {
return true;
}

/**
* Creates and returns a {@code Person} with the details of {@code personToEdit}
* edited with {@code editPersonDescriptor}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public CommandResult execute(Model model) throws CommandException {
return new CommandResult(formattedMessage);
}

@Override
public boolean isModification() {
return true;
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public CommandResult execute(Model model) throws CommandException {
return new CommandResult(MESSAGE_SUCCESS);
}

@Override
public boolean isModification() {
return true;
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class UnmarkAttendanceCommand extends Command {
public static final String MESSAGE_USAGE = generateMessageUsage(
COMMAND_WORD,
"Unmarks the attendance of the student identified by their NUSNet ID "
+ "by removing the specified week to their attendance set. ",
+ "by removing the specified week from their attendance set. ",
PARAMETER_NUSNET, PARAMETER_WEEK);

public static final String MESSAGE_UNMARKED_ATTENDANCE_SUCCESS = "Unmarked attendance for student: ";
Expand Down Expand Up @@ -82,7 +82,11 @@ public CommandResult execute(Model model) throws CommandException {
updatedPerson.getName(), updatedPerson.getNusNet(), weekNumber);

return new CommandResult(formattedMessage);
}

@Override
public boolean isModification() {
return true;
}

@Override
Expand Down
80 changes: 80 additions & 0 deletions src/test/java/seedu/address/logic/commands/CommandTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.testutil.TypicalPersons.ALICE;

import java.util.ArrayList;

import org.junit.jupiter.api.Test;

import seedu.address.commons.core.index.Index;
import seedu.address.model.course.Course;
import seedu.address.model.person.NameContainsKeywordsPredicate;
import seedu.address.model.person.NusNet;
import seedu.address.model.weeknumber.WeekNumber;

class CommandTest {

@Test
void isModification() {
NusNet genericNusNet = new NusNet("E1234567");
WeekNumber genericWeekNumber = new WeekNumber("1");
Course genericCourse = new Course("CS2103T");

// EP: AddPersonCommand
Command addCommand = new AddPersonCommand(ALICE);
assertTrue(addCommand.isModification());

// EP: ClearCommand
Command clearCommand = new ClearCommand();
assertTrue(clearCommand.isModification());

// EP: DeletePersonCommand
Command deleteCommand = new DeletePersonCommand(genericNusNet);
assertTrue(deleteCommand.isModification());

// EP: EditPersonCommand
Command editCommand = new EditPersonCommand(
Index.fromOneBased(1),
new EditPersonCommand.EditPersonDescriptor()
);
assertTrue(editCommand.isModification());

// EP: FindPersonCommand
Command findCommand = new FindPersonCommand(
new NameContainsKeywordsPredicate(new ArrayList<>())
);
assertFalse(findCommand.isModification());

// EP: ListPersonCommand
Command listCommand = new ListPersonCommand();
assertFalse(listCommand.isModification());

// EP: MarkAttendanceCommand
Command markAttendanceCommand = new MarkAttendanceCommand(
genericNusNet,
genericWeekNumber
);
assertTrue(markAttendanceCommand.isModification());

// EP: UnmarkAttendanceCommand
Command unmarkAttendanceCommand = new UnmarkAttendanceCommand(
genericNusNet,
genericWeekNumber
);
assertTrue(unmarkAttendanceCommand.isModification());

// EP: HelpCommand
Command helpCommand = new HelpCommand();
assertFalse(helpCommand.isModification());

// EP: ExitCommand
Command exitCommand = new ExitCommand();
assertFalse(exitCommand.isModification());

// EP: SetCourseCommand
Command setCourseCommand = new SetCourseCommand(genericCourse);
assertTrue(setCourseCommand.isModification());
}
}

0 comments on commit 08f6aa5

Please sign in to comment.