Skip to content

Commit

Permalink
Fix bug with cft command
Browse files Browse the repository at this point in the history
Previously, if there was 1 friend with no common free time,
cft command would only display an error saying that user and friend
have no common free times, and not proceed to show the friends that
have common free times.

This issue has been fixed. Expected output should now be:
You and Friend have no common free time!
You and John Doe have common free times at:
...
  • Loading branch information
lululwtv committed Nov 8, 2023
1 parent accb7d6 commit 8871e0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public CommandResult execute(Model model) throws CommandException {
* @return a message indicating that the user and the given friend have no common free time
*/
public static String createNoOverlapFriendMessage(Person friend) {
return "You and " + friend.getName().toString() + " have no common free time!";
return "You and " + friend.getName().toString() + " have no common free time!\n";
}

/**
Expand Down Expand Up @@ -129,7 +129,7 @@ public StringBuilder createCommonFreeTimeMessage(Person user, Person friend) thr
Schedule friendSchedule = friend.getSchedule();
List<FreeTime> commonFreeTimeWithFriend = userSchedule.getThisWeeksFreeTimesWith(friendSchedule);
if (commonFreeTimeWithFriend.isEmpty()) {
throw new CommandException(createNoOverlapFriendMessage(friend));
return new StringBuilder(createNoOverlapFriendMessage(friend));
} else {
StringBuilder sb = new StringBuilder("You have common free times with "
+ friend.getName().toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public AddScheduleCommand parse(String args) throws ParseException {
String indexString;

String eventName = argMultimap.getValue(PREFIX_EVENTNAME).get().toUpperCase();
String eventType = argMultimap.getValue(PREFIX_EVENTTYPE).get().toUpperCase();
String eventType = argMultimap.getValue(PREFIX_EVENTTYPE).get().toLowerCase();
String schedule = argMultimap.getValue(PREFIX_SCHEDULE).get();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public RemoveScheduleCommand parse(String args) throws ParseException {
try {
String indexString = argMultimap.getPreamble().toLowerCase();
String eventName = argMultimap.getValue(PREFIX_EVENTNAME).get().toUpperCase();
String eventType = argMultimap.getValue(PREFIX_EVENTTYPE).get().toUpperCase();
String eventType = argMultimap.getValue(PREFIX_EVENTTYPE).get().toLowerCase();
if (indexString.equals("user")) {
return new RemoveScheduleCommand(eventName, eventType, null);
} else if (Integer.parseInt(indexString) > 0) {
Expand Down

0 comments on commit 8871e0c

Please sign in to comment.