Skip to content

Commit

Permalink
Merge pull request #276 from ZD292/Branch-v1.4
Browse files Browse the repository at this point in the history
Add FindFreeTime test case
  • Loading branch information
coderhuang559 authored Nov 13, 2023
2 parents 371dbf7 + a4c36e2 commit 4a7dc44
Show file tree
Hide file tree
Showing 12 changed files with 1,205 additions and 14 deletions.
8 changes: 6 additions & 2 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ This guide explains how you can use ProjectPRO to add contacts and manage your g
Here are some annotations used in this guide:




<p></p>
<div style="border-left: 4px solid #56494C; background-color: #F1DEC6; color: #000; padding: 10px; margin: 5px 0; border-radius: 6px;">
<h5 style="color: #56494C; margin: 0 0 5px 0; padding: 0;"> :heavycheckmark: Acceptable values</h5>
Expand Down Expand Up @@ -619,12 +621,14 @@ You list all available time slots of your contacts.
- Provide the full name of the contact using the `n/` prefix.
<p></p>
<div style="border-left: 4px solid #56494C; background-color: #F1DEC6; color: #000; padding: 10px; margin: 5px 0; border-radius: 6px;">
<h3 style="color: #56494C; margin: 0 0 5px 0; padding: 0;">Acceptable values</h3>
<p style="color: #000; margin: 8px 0;"><code style="color: #555; background-color: #F0C481; padding: 2px; border-radius: 2px;">NAME</code>
<h4 style="color: #56494C; margin: 0 0 5px 0; padding: 0;">Acceptable values</h4>
<p style="font-size:9px; color: #000; margin: 8px 0;"><code style="color: #555; background-color: #F0C481; padding: 2px; border-radius: 2px;">NAME</code>
must be alphanumeric and cannot be blank.</p>
</div>

<p></p>


**Example(s):**
- `listtime n/Alex Yeoh`
This lists all time slots when Alex Yeoh is available from your contact list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,24 @@ public boolean equals(Object other) {
}

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

GroupPersonCommand otherGroupPersonCommand = (GroupPersonCommand) other;
FindFreeTimeCommand otherFindFreeTimeCommand = (FindFreeTimeCommand) other;
// to check
return this.equals(otherGroupPersonCommand);
return this.duration.getDurationInMin() == otherFindFreeTimeCommand.duration.getDurationInMin()
&& this.groupName.equals(otherFindFreeTimeCommand.groupName);

}

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

5 changes: 5 additions & 0 deletions src/main/java/seedu/address/model/Duration.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public int getDurationInMin() {
return this.duration;
}

public String toString() {
return Integer.toString(duration);
}


}
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/group/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public TimeIntervalList findFreeTime(Duration duration) throws CommandException
freeTime = freeTime.findOverlap(second, duration);
}
}

return freeTime;
}

Expand Down
15 changes: 15 additions & 0 deletions src/test/java/seedu/address/logic/commands/CommandTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DURATION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_FREETIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GROUPREMARK;
Expand Down Expand Up @@ -95,6 +96,20 @@ public class CommandTestUtil {
public static final String VALID_GROUP_REMARK_OTHERS = "gU4&😊!";
public static final String GROUP_REMARK_OTHERS_DESC = " " + PREFIX_GROUPREMARK + VALID_GROUP_REMARK_OTHERS;

public static final String DURATION_THIRTY = "30";
public static final String VALID_DURATION_THIRTY = " " + PREFIX_DURATION + DURATION_THIRTY;
public static final String INVALID_DURATION_NEGATIVE = "-1";
public static final String INVALID_DURATION_NEGATIVE_DESC = " " + PREFIX_DURATION + INVALID_DURATION_NEGATIVE;
public static final String INVALID_DURATION_ZERO = "0";
public static final String INVALID_DURATION_ZERO_DESC = " " + PREFIX_DURATION + INVALID_DURATION_ZERO;
public static final String INVALID_DURATION_MAX = "10080";
public static final String INVALID_DURATION_MAX_DESC = " " + PREFIX_DURATION + INVALID_DURATION_MAX;

public static final String INVALID_DURATION_CHAR = "aaa";
public static final String INVALID_DURATION_CHAR_DESC = " " + PREFIX_DURATION + INVALID_DURATION_CHAR;





/**
Expand Down
Loading

0 comments on commit 4a7dc44

Please sign in to comment.