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

Reduce codestyle violations from 250 plus to 100 plus #222

Merged
merged 9 commits into from
Nov 4, 2023
34 changes: 29 additions & 5 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ You can create a group in your contact list.
You can delete a group in your contact list.


**Format:** `delete n/GROUP_NAME`
**Format:** `delete g/GROUP_NAME`


**Acceptable values:**
Expand All @@ -285,6 +285,28 @@ You can delete a group in your contact list.



### Adding remarks to a group `remark`
You can add remarks to a group in your contact list.


**Format:** `remark g/GROUP_NAME r/REMARK`


**Acceptable values:**
- `GROUP_NAME` must be alphanumeric and cannot be blank.
- `GROUP_NAME` must be an existing group in the contact list.
- `REMARK` must be alphanumeric.

**Example(s):**
- `remark g/CS2103T r/quiz tomorrow`
This adds the remark "quiz tomorrow" to the existing "CS2103T" group in your contact list.


**Potential errors(s):**
- Incorrect format (e.g. no prefix):
- The group you entered does not exist in your contact list:



### Finding a group `find`
You can find a group in your contact list. This allows you to view the group's members and remarks.
Expand All @@ -303,7 +325,7 @@ You can find a group in your contact list. This allows you to view the group's m


**Potential error(s):**
- Incorrect format (e.g., no prefix):
- Incorrect format (e.g. no prefix):


- The group you are trying to find does not exist in your contact list:
Expand Down Expand Up @@ -554,17 +576,19 @@ You list meeting time for your groups.
You can find a meeting time slot for your group where everyone is available.


**Format:** `findfreetime g/GROUP_NAME`
**Format:** `findfreetime g/GROUP_NAME d/DURATION`
- Provide the full name of the group using the `g/` prefix.
- Provide the duration of the meeting using the `d/` prefix.


**Acceptable values:**
- `GROUP_NAME` must be alphanumeric.
- `DURATION` must be an integer representing the meeting duration in minutes.


**Example(s):**
- `findfreetime g/CS2100`
This finds a common meeting time for your CS2100 group.
- `findfreetime g/CS2100 d/60`
This finds a common meeting time of 60 minutes for your CS2100 group.
Insert Image


Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public class AddCommand extends Command {

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "%1$s is already in the contact list";
public static final String MESSAGE_DUPLICATE_EMAIL = "This email: %1$s already belongs to some one in the contact list";
public static final String MESSAGE_DUPLICATE_PHONE = "This phone number: %1$s belongs to some one in the contact list";
public static final String MESSAGE_DUPLICATE_EMAIL = "This email: %1$s already belongs to some "
+ "one in the contact list";
public static final String MESSAGE_DUPLICATE_PHONE = "This phone number: %1$s belongs to some one "
+ "in the contact list";

private final Person toAdd;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AddGroupMeetingTimeCommand extends Command {
+ PREFIX_FREETIME + "MEETING_TIME \n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_GROUPTAG + "CS2103T "
+ PREFIX_FREETIME + "mon 1200 - mon 1400 ;tue 1000 - wed 1600";
+ PREFIX_FREETIME + "mon 1200 - mon 1400 " + PREFIX_FREETIME + "wed 1000 - wed 1600";

public static final String MESSAGE_NO_GROUP_WITH_NAME_FOUND = "No group with such name found.\n"
+ "Please provide the group's full name as in the existing contact list.";
Expand Down
158 changes: 79 additions & 79 deletions src/main/java/seedu/address/logic/commands/FindFreeTimeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,84 +19,84 @@
*/
public class FindFreeTimeCommand extends Command {

public static final String COMMAND_WORD = "findfreetime";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds a free time slot given a group and duration \n" +
"Parameters: " + PREFIX_GROUPTAG + "GROUPNAME " + PREFIX_DURATION + "DURATION";

public static final String MESSAGE_DURATION_USAGE = "Enter Duration in minutes";


public static final String MESSAGE_NOT_ALL_FREE = "%s has not input their free time yet\n";

public static final String MESSAGE_SUCCESS = "These are the available timeslots \n";
public static final String MESSAGE_INTERVAL_DISPLAY = "%d. %s\n";

private final String groupName;
private final Duration duration;


/**
* Creates an AddCommand to add the specified {@code Person}
*/
public FindFreeTimeCommand(String groupName, Duration duration) {
requireNonNull(groupName);
requireNonNull(duration);
this.groupName = groupName;
this.duration = duration;
}

@Override
public CommandResult execute(Model model) throws CommandException {
// 3 steps
// find group, if group exists check everybody input time, use find free time algo
requireNonNull(model);
Group g;
// br stores message
StringBuilder br = new StringBuilder();
int intervalCounter = 1;
try {
g = model.findGroup(groupName);
} catch (GroupNotFoundException e) {
throw new CommandException(e.getMessage());
}

// check everybody input time, modify br should somebody not key in their free time
g.areAllFree(br, MESSAGE_NOT_ALL_FREE);
if (br.length() != 0) {
throw new CommandException(br.toString());
}

// use algorithm to findFreeTime()
TimeIntervalList freeTime = g.findFreeTime(duration);
freeTime.getMessage(br, MESSAGE_INTERVAL_DISPLAY);

return new CommandResult(MESSAGE_SUCCESS + br.toString());
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof GroupPersonCommand)) {
return false;
}

GroupPersonCommand otherGroupPersonCommand = (GroupPersonCommand) other;
// to check
return this.equals(otherGroupPersonCommand);

}

// to fix
@Override
public java.lang.String toString() {
return new ToStringBuilder(this)
.add("toAddToGroup", "")
.toString();
}
public static final String COMMAND_WORD = "findfreetime";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds a free time slot given a group and duration \n" +
"Parameters: " + PREFIX_GROUPTAG + "GROUPNAME " + PREFIX_DURATION + "DURATION";

public static final String MESSAGE_DURATION_USAGE = "Enter Duration in minutes";


public static final String MESSAGE_NOT_ALL_FREE = "%s has not input their free time yet\n";

public static final String MESSAGE_SUCCESS = "These are the available timeslots \n";
public static final String MESSAGE_INTERVAL_DISPLAY = "%d. %s\n";

private final String groupName;
private final Duration duration;


/**
* Creates an AddCommand to add the specified {@code Person}
*/
public FindFreeTimeCommand(String groupName, Duration duration) {
requireNonNull(groupName);
requireNonNull(duration);
this.groupName = groupName;
this.duration = duration;
}

@Override
public CommandResult execute(Model model) throws CommandException {
// 3 steps
// find group, if group exists check everybody input time, use find free time algo
requireNonNull(model);
Group g;
// br stores message
StringBuilder br = new StringBuilder();
int intervalCounter = 1;
try {
g = model.findGroup(groupName);
} catch (GroupNotFoundException e) {
throw new CommandException(e.getMessage());
}

// check everybody input time, modify br should somebody not key in their free time
g.areAllFree(br, MESSAGE_NOT_ALL_FREE);
if (br.length() != 0) {
throw new CommandException(br.toString());
}

// use algorithm to findFreeTime()
TimeIntervalList freeTime = g.findFreeTime(duration);
freeTime.getMessage(br, MESSAGE_INTERVAL_DISPLAY);

return new CommandResult(MESSAGE_SUCCESS + br.toString());
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof GroupPersonCommand)) {
return false;
}

GroupPersonCommand otherGroupPersonCommand = (GroupPersonCommand) other;
// to check
return this.equals(otherGroupPersonCommand);

}

// to fix
@Override
public java.lang.String toString() {
return new ToStringBuilder(this)
.add("toAddToGroup", "")
.toString();
}
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package seedu.address.logic.parser;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ENDINTERVAL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_FREETIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;

Expand All @@ -13,7 +12,9 @@
import seedu.address.model.TimeInterval;
import seedu.address.model.person.Name;


/**
* Parses input arguments and creates a new AddTimeCommand object
*/
public class AddTimeCommandParser implements Parser<AddTimeCommand> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.*;

public class DeleteTimeCommandParser implements Parser<DeleteTimeCommand>{
public class DeleteTimeCommandParser implements Parser<DeleteTimeCommand> {

/**
* Parses the given {@code String} of arguments in the context of the DeleteTimeCommand
Expand All @@ -22,20 +22,21 @@ public DeleteTimeCommand parse(String args) throws ParseException {
String trimmedArgs = args.trim();
if (trimmedArgs.isEmpty()) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteTimeCommand.MESSAGE_USAGE));
String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteTimeCommand.MESSAGE_USAGE));
}

ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_GROUPTAG, PREFIX_FREETIME);
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_GROUPTAG, PREFIX_FREETIME);

if (!arePrefixesPresent(argMultimap, PREFIX_FREETIME)|| !argMultimap.getPreamble().isEmpty()) {
if (!arePrefixesPresent(argMultimap, PREFIX_FREETIME) || !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteTimeCommand.MESSAGE_USAGE));
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_GROUPTAG);
ArrayList<TimeInterval> timeInterval = ParserUtil.parseInterval(argMultimap.getAllValues(PREFIX_FREETIME));
if ((arePrefixesPresent(argMultimap, PREFIX_NAME) && arePrefixesPresent(argMultimap, PREFIX_GROUPTAG))) {
throw new ParseException(String.format(DeleteCommand.MESSAGE_TWO_PARAMETERS, DeleteTimeCommand.MESSAGE_USAGE));
throw new ParseException(
String.format(DeleteCommand.MESSAGE_TWO_PARAMETERS, DeleteTimeCommand.MESSAGE_USAGE));
}
if (arePrefixesPresent(argMultimap, PREFIX_NAME)) {
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
Expand Down
Loading