Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create NegateCommand abstract class and add unremind command #118

Merged

Conversation

ChooJiaXin
Copy link
Collaborator

@ChooJiaXin ChooJiaXin commented Oct 16, 2020

closes #109
closes #113

Implemented unremind command as well to ensure the correctness of NegateCommand class

@ChooJiaXin ChooJiaXin added this to the v1.3 milestone Oct 16, 2020
@ChooJiaXin ChooJiaXin self-assigned this Oct 16, 2020
@ChooJiaXin ChooJiaXin changed the title Create NegateCommand abstract class Create NegateCommand abstract class and add unremind command Oct 16, 2020
@codecov-io
Copy link

Codecov Report

Merging #118 into master will increase coverage by 0.58%.
The diff coverage is 85.71%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #118      +/-   ##
============================================
+ Coverage     55.48%   56.07%   +0.58%     
- Complexity      447      461      +14     
============================================
  Files            90       93       +3     
  Lines          1768     1803      +35     
  Branches        209      213       +4     
============================================
+ Hits            981     1011      +30     
- Misses          739      740       +1     
- Partials         48       52       +4     
Impacted Files Coverage Δ Complexity Δ
...va/seedu/address/logic/commands/RemindCommand.java 84.00% <ø> (ø) 10.00 <0.00> (ø)
.../seedu/address/logic/parser/AddressBookParser.java 80.00% <0.00%> (-4.22%) 12.00 <0.00> (ø)
...eedu/address/logic/parser/RemindCommandParser.java 100.00% <ø> (ø) 2.00 <0.00> (ø)
.../seedu/address/logic/commands/UnremindCommand.java 82.60% <82.60%> (ø) 10.00 <10.00> (?)
...va/seedu/address/logic/commands/NegateCommand.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)
...du/address/logic/parser/UnremindCommandParser.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5455e5b...08940bd. Read the comment docs.

Copy link
Collaborator

@itsjerryho itsjerryho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a few comments haha

@@ -10,7 +10,7 @@

/**
* Parses the given {@code String} of arguments in the context of the DeleteCommand
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to be 'in the context of RemindCommand' instead of DeleteCommand?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yup. Must have missed it out. I shall go change it now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended!

/**
* Represents a command with hidden internal logic and the ability to reverse the execution of other commands.
*/
public abstract class NegateCommand extends Command {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it have to be abstract since this class doesn't contain any abstract methods.. I think a normal class would suffice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first, I made it a non-abstract class, but then IntelliJ made noise because it extends abstract class Command so i either had to override the execute method in NegataCommand or make NegateCommand abstract. Since I personally felt that overriding the execute method in NegateCommand was a little redundant since the UnremindCommand, UnscheduleCommand and UndoneCommand will override the execute method again, I decided to make the NegateCommand class abstract.

I can change it back to a normal class if you want to though, I shall just override the abstract execute method in NegateCommand if you want to change it to a normal class :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just keep it as an abstract class will do.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh okay, I didn't know that Command was abstract. ya we can leave it as abstract then

public class UnremindCommandParser implements Parser<UnremindCommand> {

/**
* Parses the given {@code String} of arguments in the context of the DeleteCommand
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnremindCommand?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended!

model.setAssignment(assignmentInList, assignmentInListReminded);
}

// Reminded first assignment in filtered list
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second* assignment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended!

Copy link
Collaborator

@hyngkng hyngkng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. :) I think the abstract class issue is minor and we can leave it as it is for now.

/**
* Represents a command with hidden internal logic and the ability to reverse the execution of other commands.
*/
public abstract class NegateCommand extends Command {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just keep it as an abstract class will do.

throw new CommandException(MESSAGE_UNREMINDED_ASSIGNMENT);
}

assert(assignmentToUnremind.isReminded());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good assertion.

import seedu.address.model.assignment.Assignment;
import seedu.address.testutil.AssignmentBuilder;

public class UnremindCommandTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test cases. They cover every case I can think of, so good job.

Copy link
Collaborator

@itsjerryho itsjerryho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :)

@ChooJiaXin ChooJiaXin merged commit 24463b4 into AY2021S1-CS2103T-F11-3:master Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unremind command Add NegateCommand
4 participants