forked from nus-cs2103-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/AY2324S2-CS2103-F08-3/tp
- Loading branch information
Showing
9 changed files
with
591 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ StaffConnect (SC) is a **desktop app for managing contacts of Professors and Tut | |
|
||
* `list` : Lists all contacts. | ||
|
||
* `add n/John Doe p/98765432 e/[email protected] v/John street, block 123, #01-01` : Adds a contact named `John Doe` to the contacts list. | ||
* `add n/John Doe p/98765432 e/[email protected] v/John street, block 123, #01-01 m/CS2103` : Adds a contact named `John Doe` to the contacts list. | ||
|
||
* `delete 3` : Deletes the 3rd contact shown in the current list. | ||
|
||
|
@@ -76,15 +76,15 @@ Format: `help` | |
|
||
Adds a person to the contacts. | ||
|
||
Format: `add n/NAME p/PHONE_NUMBER e/EMAIL v/VENUE [t/TAG]…` | ||
Format: `add n/NAME p/PHONE_NUMBER e/EMAIL v/VENUE m/MODULE [t/TAG]…` | ||
|
||
<div markdown="span" class="alert alert-primary">:bulb: **Tip:** | ||
A person can have any number of tags (including 0) | ||
</div> | ||
|
||
Examples: | ||
* `add n/John Doe p/98765432 e/[email protected] v/John street, block 123, #01-01` | ||
* `add n/Betsy Crowe t/friend e/[email protected] v/Newgate Prison p/1234567 t/criminal` | ||
* `add n/John Doe p/98765432 e/[email protected] v/John street, block 123, #01-01 m/CS2103` | ||
* `add n/Betsy Crowe t/friend m/CS2103T e/[email protected] v/Newgate Prison p/1234567 t/criminal` | ||
|
||
### Listing all persons : `list` | ||
|
||
|
@@ -96,7 +96,7 @@ Format: `list` | |
|
||
Edits an existing person in the contacts. | ||
|
||
Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [v/VENUE] [t/TAG]…` | ||
Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [v/VENUE] [m/MODULE] [t/TAG]…` | ||
|
||
* Edits the person at the specified `INDEX`. The index refers to the index number shown in the displayed person list. The index **must be a positive integer** 1, 2, 3, … | ||
* At least one of the optional fields must be provided. | ||
|
@@ -159,7 +159,7 @@ StaffConnect data are saved in the hard disk automatically after any command tha | |
|
||
### Editing the data file | ||
|
||
StaffConnect data are saved automatically as a JSON file `[JAR file location]/data/StaffConnect.json`. Advanced users are welcome to update data directly by editing that data file. | ||
StaffConnect data are saved automatically as a JSON file `[JAR file location]/data/staffconnect.json`. Advanced users are welcome to update data directly by editing that data file. | ||
|
||
<div markdown="span" class="alert alert-warning">:exclamation: **Caution:** | ||
If your changes to the data file makes its format invalid, StaffConnect will discard all data and start with an empty data file at the next run. Hence, it is recommended to take a backup of the file before editing it.<br> | ||
|
@@ -189,10 +189,10 @@ _Details coming soon ..._ | |
|
||
Action | Format, Examples | ||
--------|------------------ | ||
**Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL v/VENUE [t/TAG]…` <br> e.g., `add n/James Ho p/22224444 e/[email protected] v/123, Clementi Rd, 1234665 t/friend t/colleague` | ||
**Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL v/VENUE m/MODULE [t/TAG]…` <br> e.g., `add n/James Ho p/22224444 e/[email protected] v/123, Clementi Rd, 1234665 m/CS2103 t/friend t/colleague` | ||
**Clear** | `clear` | ||
**Delete** | `delete INDEX`<br> e.g., `delete 3` | ||
**Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [v/VENUE] [t/TAG]…`<br> e.g.,`edit 2 n/James Lee e/[email protected]` | ||
**Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [v/VENUE] [m/MODULE] [t/TAG]…`<br> e.g.,`edit 2 n/James Lee e/[email protected]` | ||
**Find** | `find KEYWORD [MORE_KEYWORDS]`<br> e.g., `find James Jake` | ||
**List** | `list` | ||
**Help** | `help` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package staffconnect.model.meeting; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static staffconnect.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents a Meeting's description in the staff book. | ||
* Guarantees: immutable; is valid as declared in {@link #isValidDescription(String)} | ||
*/ | ||
public class Description { | ||
|
||
public static final String MESSAGE_CONSTRAINTS = | ||
"Description should only contain alphanumeric characters and spaces, and it should not be blank"; | ||
|
||
/* | ||
* The first character of the name must not be a whitespace, | ||
* otherwise " " (a blank string) becomes a valid input. | ||
*/ | ||
public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; | ||
|
||
public final String description; | ||
|
||
/** | ||
* Constructs a {@code Description}. | ||
* | ||
* @param textDescription A valid description. | ||
*/ | ||
public Description(String textDescription) { | ||
requireNonNull(textDescription); | ||
checkArgument(isValidDescription(textDescription), MESSAGE_CONSTRAINTS); | ||
description = textDescription; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid description. | ||
*/ | ||
public static boolean isValidDescription(String test) { | ||
return test.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return description.hashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof Description)) { | ||
return false; | ||
} | ||
|
||
Description otherDecription = (Description) other; | ||
return description.equals(otherDecription.description); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return description; | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/staffconnect/model/meeting/MeetDateTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package staffconnect.model.meeting; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static staffconnect.commons.util.AppUtil.checkArgument; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
/** | ||
* Represents a Meeting's starting time in the staff book. | ||
* Guarantees: immutable; is valid as declared in {@link #isValidMeetDateTime(String)} | ||
*/ | ||
public class MeetDateTime { | ||
|
||
public static final String MESSAGE_CONSTRAINTS = "DateTime should be of the correct format dd/mm/yyyy HH:mm"; | ||
public static final String VALIDATION_REGEX = "\\d{2}/\\d{2}/\\d{4} \\d{2}:\\d{2}"; | ||
|
||
private static final DateTimeFormatter PROCESS_FORMAT = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"); | ||
|
||
private final LocalDateTime value; | ||
|
||
|
||
/** | ||
* Constructs a {@code MeetDateTime}. | ||
* | ||
* @param date A valid date. | ||
*/ | ||
public MeetDateTime(String date) { | ||
requireNonNull(date); | ||
checkArgument(isValidMeetDateTime(date), MESSAGE_CONSTRAINTS); | ||
value = java.time.LocalDateTime.parse(date, PROCESS_FORMAT); | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid date. | ||
*/ | ||
public static boolean isValidMeetDateTime(String test) { | ||
return test.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof MeetDateTime)) { | ||
return false; | ||
} | ||
|
||
MeetDateTime otherDate = (MeetDateTime) other; | ||
return value.equals(otherDate.value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value.format(PROCESS_FORMAT); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package staffconnect.model.meeting; | ||
|
||
|
||
import static staffconnect.commons.util.CollectionUtil.requireAllNonNull; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Represents a Meeting event in the staff book. | ||
* Guarantees: details are present and not null, field values are validated, immutable. | ||
*/ | ||
public class Meeting { | ||
|
||
private final Description description; | ||
private final MeetDateTime startDate; | ||
|
||
/** | ||
* Constructs a {@code Meeting}. | ||
* | ||
* @param description A valid meeting description. | ||
* @param startDate A valid time and date for the meeting. | ||
*/ | ||
|
||
public Meeting(Description description, MeetDateTime startDate) { | ||
requireAllNonNull(description, startDate); | ||
this.description = description; | ||
this.startDate = startDate; | ||
} | ||
|
||
public Description getDescription() { | ||
return description; | ||
} | ||
|
||
public MeetDateTime getStartDate() { | ||
return startDate; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(description, startDate); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof Meeting)) { | ||
return false; | ||
} | ||
|
||
Meeting otherMeeting = (Meeting) other; | ||
return description.equals(otherMeeting.description) && startDate.equals(otherMeeting.startDate); | ||
} | ||
|
||
/** | ||
* Format state as text for viewing. | ||
*/ | ||
public String toString() { | ||
return startDate + ":" + description; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package staffconnect.model.person; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static staffconnect.commons.util.AppUtil.checkArgument; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Represents a Person's faculty in the staff book. | ||
* Guarantees: immutable; is valid as declared in | ||
* {@link #isValidFaculty(String)} | ||
*/ | ||
public class Faculty { | ||
public static final String MESSAGE_CONSTRAINTS = | ||
"The content should be a String representing a real faculty of NUS"; | ||
|
||
/** | ||
* For this version, a valid faculty value should match exactly the full name of the faculty, | ||
* or the value is invalid. The enum class serves as the purpose for parsing user strings into the faculty name. | ||
*/ | ||
public enum FacultyName { | ||
ARTS_AND_SOCIAL_SCIENCES("Arts and Social Sciences"), | ||
BUSINESS("Business"), | ||
COMPUTING("Computing"), | ||
CONTINUING_AND_LIFELONG_EDUCATION("Continuing and Lifelong Education"), | ||
DENTISTRY("Dentistry"), | ||
DESIGN_AND_ENVIRONMENT("Design and Environment"), | ||
DUKE_NUS_MEDICAL_SCHOOL("Duke-NUS Medical School"), | ||
ENGINEERING("Engineering"), | ||
INTEGRATIVE_SCIENCES_AND_ENGINEERING("Integrative Sciences and Engineering"), | ||
LAW("Law"), | ||
MEDICINE("Medicine"), | ||
MUSIC("Music"), | ||
PUBLIC_HEALTH("Public Health"), | ||
PUBLIC_POLICY("Public Policy"), | ||
SCIENCE("Science"), | ||
UNIVERSITY_SCHOLARS_PROGRAMME("University Scholars Programme"), | ||
YALE_NUS_COLLEGE("Yale-NUS College"); | ||
|
||
private final String facultyNameValue; | ||
|
||
FacultyName(String facultyName) { | ||
this.facultyNameValue = facultyName; | ||
} | ||
|
||
/** | ||
* Links enum member to its name. | ||
* | ||
* @return name of the faculty | ||
*/ | ||
public String getFacultyName() { | ||
return facultyNameValue; | ||
} | ||
} | ||
public final FacultyName value; | ||
|
||
/** | ||
* Constructs a {@code Faculty}. | ||
* | ||
* @param faculty A valid faculty. | ||
*/ | ||
public Faculty(String faculty) { | ||
requireNonNull(faculty); | ||
checkArgument(isValidFaculty(faculty), MESSAGE_CONSTRAINTS); | ||
value = fromString(faculty); // can be extended | ||
} | ||
|
||
/** | ||
* Verifies if a faculty name is valid. | ||
* | ||
* @param test string representing the faculty name | ||
* @return True if the input matches any faculty name. | ||
*/ | ||
public static boolean isValidFaculty(String test) { | ||
requireNonNull(test, "faculty cannot be null"); | ||
|
||
return Arrays.stream(FacultyName.values()) | ||
.anyMatch(faculty -> faculty.getFacultyName().equalsIgnoreCase(test)); | ||
} | ||
|
||
private static FacultyName fromString(String name) { | ||
for (FacultyName faculty : FacultyName.values()) { | ||
if (faculty.getFacultyName().equalsIgnoreCase(name)) { | ||
return faculty; | ||
} | ||
} | ||
throw new IllegalArgumentException("No enum constant matches the provided name: " + name); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value.getFacultyName(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) { | ||
return true; | ||
} | ||
|
||
if (!(obj instanceof Faculty)) { | ||
return false; | ||
} | ||
|
||
Faculty otherFaculty = (Faculty) obj; | ||
return this.value.equals(otherFaculty.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
} | ||
} |
Oops, something went wrong.