forked from CS2113-AY1819S2-T08-3/main
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from CS2113-AY1819S2-T08-3/master
Merge Refactor
- Loading branch information
Showing
19 changed files
with
469 additions
and
77 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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<AddressBook/> | ||
<Planner/> |
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
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
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
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,53 @@ | ||
package planmysem.data.slot; | ||
|
||
import planmysem.data.exception.IllegalValueException; | ||
|
||
/** | ||
* Represents a Person's email in the address book. | ||
* Guarantees: immutable; is valid as declared in {@link #isValid(String)} | ||
*/ | ||
public class DateTime { | ||
|
||
public static final String EXAMPLE = "[email protected]"; | ||
public static final String MESSAGE_EMAIL_CONSTRAINTS = | ||
"Person emails should be 2 alphanumeric/period strings separated by '@'"; | ||
public static final String EMAIL_VALIDATION_REGEX = "[\\w\\.]+@[\\w\\.]+"; | ||
|
||
public final String value; | ||
private boolean isPrivate; | ||
|
||
/** | ||
* Validates given email. | ||
* | ||
* @throws IllegalValueException if given email address string is invalid. | ||
*/ | ||
public DateTime(String value, boolean isPrivate) throws IllegalValueException { | ||
this.isPrivate = isPrivate; | ||
String dateTime = value.trim(); | ||
if (!isValid(dateTime)) { | ||
throw new IllegalValueException(MESSAGE_EMAIL_CONSTRAINTS); | ||
} | ||
this.value = dateTime; | ||
} | ||
|
||
/** | ||
* Checks if a given string is a valid Date and Time. | ||
*/ | ||
public static boolean isValid(String test) { | ||
return test.matches(EMAIL_VALIDATION_REGEX); | ||
} | ||
|
||
public boolean isPrivate() { | ||
return isPrivate; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
} | ||
} |
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,68 @@ | ||
package planmysem.data.slot; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import planmysem.data.exception.IllegalValueException; | ||
|
||
/** | ||
* Represents a Slot's description in the address book. | ||
* Guarantees: immutable; is valid as declared in {@link #isValidName(String)} | ||
*/ | ||
public class Description { | ||
|
||
public static final String EXAMPLE = "John Doe"; | ||
public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphanumeric characters"; | ||
public static final String NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+"; | ||
|
||
public final String fullName; | ||
private boolean isPrivate; | ||
|
||
/** | ||
* Validates given name. | ||
* | ||
* @throws IllegalValueException if given name string is invalid. | ||
*/ | ||
public Description(String value) throws IllegalValueException { | ||
String description = value.trim(); | ||
if (!isValidName(description)) { | ||
throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS); | ||
} | ||
this.fullName = description; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid slot name. | ||
*/ | ||
public static boolean isValidName(String test) { | ||
return test.matches(NAME_VALIDATION_REGEX); | ||
} | ||
|
||
/** | ||
* Retrieves a listing of every word in the name, in order. | ||
*/ | ||
public List<String> getWordsInName() { | ||
return Arrays.asList(fullName.split("\\s+")); | ||
} | ||
public boolean isPrivate() { | ||
return isPrivate; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return fullName; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof Description // instanceof handles nulls | ||
&& this.fullName.equals(((Description) other).fullName)); // state check | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return fullName.hashCode(); | ||
} | ||
|
||
} |
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,14 @@ | ||
package planmysem.data.slot; | ||
|
||
/** | ||
* Represents a Person's email in the address book. | ||
* Guarantees: immutable; is valid as declared in {@link #isValid(String)} | ||
*/ | ||
public class Location { | ||
private boolean isPrivate; | ||
|
||
public boolean isPrivate() { | ||
return isPrivate; | ||
} | ||
|
||
} |
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,64 @@ | ||
package planmysem.data.slot; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import planmysem.data.exception.IllegalValueException; | ||
|
||
/** | ||
* Represents a Slot's name in the address book. | ||
* Guarantees: immutable; is valid as declared in {@link #isValidName(String)} | ||
*/ | ||
public class Name { | ||
|
||
public static final String EXAMPLE = "John Doe"; | ||
public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphanumeric characters"; | ||
public static final String NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+"; | ||
|
||
public final String fullName; | ||
|
||
/** | ||
* Validates given name. | ||
* | ||
* @throws IllegalValueException if given name string is invalid. | ||
*/ | ||
public Name(String value) throws IllegalValueException { | ||
String name = value.trim(); | ||
if (!isValidName(name)) { | ||
throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS); | ||
} | ||
this.fullName = name; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid slot name. | ||
*/ | ||
public static boolean isValidName(String test) { | ||
return test.matches(NAME_VALIDATION_REGEX); | ||
} | ||
|
||
/** | ||
* Retrieves a listing of every word in the name, in order. | ||
*/ | ||
public List<String> getWordsInName() { | ||
return Arrays.asList(fullName.split("\\s+")); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return fullName; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof Name // instanceof handles nulls | ||
&& this.fullName.equals(((Name) other).fullName)); // state check | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return fullName.hashCode(); | ||
} | ||
|
||
} |
Oops, something went wrong.