Skip to content

Commit

Permalink
Merge pull request #267 from andrefoo/master
Browse files Browse the repository at this point in the history
Bug fix: Wrong error message in CommonFreeTimeCommand
  • Loading branch information
kristayeo authored Nov 9, 2023
2 parents 41042ec + 8135346 commit def3461
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ public CommandResult execute(Model model) throws CommandException {
return new CommandResult(createCommonFreeTimeMessage(overlappingContacts, user).toString());
}
} else {
List<Person> lastShownList = model.getFilteredPersonList();
if (index.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}
try {
List<Person> lastShownList = model.getFilteredPersonList();
if (index.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

Person friend = lastShownList.get(index.getZeroBased());

return new CommandResult(createCommonFreeTimeMessage(user, friend).toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Command parseCommand(String userInput) throws ParseException {
return new RemoveReminderCommandParser().parse(arguments);

case CommonFreetimeCommand.COMMAND_WORD:
return new CommonFreetimeCommandParser().parse(arguments);
return new CommonFreeTimeCommandParser().parse(arguments);

case AddEventCommand.COMMAND_WORD:
return new AddEventCommandParser().parse(arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Parses input arguments and creates a new CommonFreetimeCommand object.
*/
public class CommonFreetimeCommandParser implements Parser<CommonFreetimeCommand> {
public class CommonFreeTimeCommandParser implements Parser<CommonFreetimeCommand> {

/**
* Parses the given {@code String} of arguments in the context of the CommonFreetimeCommand
Expand Down
19 changes: 4 additions & 15 deletions src/main/java/seedu/address/model/person/timetable/Schedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,21 +369,6 @@ public void deleteCca(String ccaName) throws CommandException {
}
}

/**
* Adds a dated event to the schedule.
*
* @param eventString String representation of the dated event.
*/
public void addDatedEvent(String eventString) {
DatedEvent newEvent = DatedEvent.newDatedEvent(eventString);
if (!isOverlapping(newEvent)) {
datedEventsList.add(newEvent);
} else {
throw new CommandException("Cca " + ccaName + " does not exist!\n"
+ "Please check that you have entered the correct cca name!\n");
}
}

/**
* Returns true if the given event overlaps with any event in the schedule
* @param event the event to be checked
Expand Down Expand Up @@ -521,4 +506,8 @@ public boolean equals(Object other) {
public int hashCode() {
return toString().hashCode();
}

public static void main(String[] args) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Contains integration tests (interaction with the Model) for {@code CommonFreeTimeCommand}.
*/

public class CommonFreetimeCommandTest {
public class CommonFreeTimeCommandTest {
private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs(), new UserData());
private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs(), new UserData());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import seedu.address.logic.commands.CommonFreetimeCommand;
import seedu.address.logic.parser.exceptions.ParseException;

public class CommonFreetimeCommandParserTest {
private CommonFreetimeCommandParser parser = new CommonFreetimeCommandParser();
public class CommonFreeTimeCommandParserTest {
private CommonFreeTimeCommandParser parser = new CommonFreeTimeCommandParser();

@Test
public void parse_validArgs_returnsCommonFreetimeCommand() throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void editName_success() {
assertThrows(IllegalArgumentException.class, () -> module.editName(""));
}


@Test
public void isModule_success() {
Module module = new Module("CS2103", "monday 1200 1400");
Expand Down Expand Up @@ -92,8 +91,11 @@ public void isValidModuleName() {
assertFalse(Module.isValidModuleName("CS")); // only alphbets

// valid name
assertTrue(Cca.isValidCcaName("CS2103")); // alphanumeric characters
assertTrue(Cca.isValidCcaName("cs2103")); // with small letters
assertTrue(Module.isValidModuleName("CS210")); // 3 numbers
assertTrue(Module.isValidModuleName("CSS210")); // 3 starting alphabets
assertTrue(Module.isValidModuleName("CS2101S")); // less numbers
assertTrue(Module.isValidModuleName("CS2103")); // alphanumeric characters
assertTrue(Module.isValidModuleName("cs2103")); // with small letters
}

@Test
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/seedu/address/testutil/TypicalSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public class TypicalSchedule {
.build();

public static final Schedule FULL_SCHEDULE = new ScheduleBuilder()
.withModule(new Module("CS2103", "Monday 0000 2330"))
.withModule(new Module("CS2101", "Tuesday 0000 2330"))
.withModule(new Module("CS2100", "Wednesday 0000 2330"))
.withModule(new Module("CS2103", "Thursday 0000 2330"))
.withModule(new Module("CS2101", "Friday 0000 2330"))
.withModule(new Module("CS2100", "Saturday 0000 2330"))
.withModule(new Module("CS2103", "Sunday 0000 2330"))
.withModule(new Module("CS2103", "Monday 0000 2400"))
.withModule(new Module("CS2101", "Tuesday 0000 2400"))
.withModule(new Module("CS2100", "Wednesday 0000 2400"))
.withModule(new Module("CS2103", "Thursday 0000 2400"))
.withModule(new Module("CS2101", "Friday 0000 2400"))
.withModule(new Module("CS2100", "Saturday 0000 2400"))
.withModule(new Module("CS2103", "Sunday 0000 2400"))
.build();

public static final Schedule FILLED_SCHEDULE = new ScheduleBuilder()
Expand Down

0 comments on commit def3461

Please sign in to comment.