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' into update-DG
- Loading branch information
Showing
21 changed files
with
756 additions
and
234 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
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
53 changes: 53 additions & 0 deletions
53
src/main/java/seedu/address/model/person/AdmissionDate.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,53 @@ | ||
package seedu.address.model.person; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents a patient's admission date in the address book. | ||
*/ | ||
public class AdmissionDate { | ||
public static final String MESSAGE_CONSTRAINTS = | ||
"Admission dates can take any date, and it should be in DD/MM/YYYY"; | ||
public static final String VALIDATION_REGEX = "^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/[0-9]{4}$"; | ||
|
||
public final String value; | ||
|
||
/** | ||
* Constructs a {@code AdmissionDate}. | ||
* | ||
* @param value A valid admission date. | ||
*/ | ||
public AdmissionDate(String value) { | ||
requireNonNull(value); | ||
checkArgument(isValidAdmissionDate(value), MESSAGE_CONSTRAINTS); | ||
this.value = value; | ||
} | ||
public static boolean isValidAdmissionDate(String admissionDate) { | ||
return admissionDate.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value.toString(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
if (!(other instanceof AdmissionDate)) { | ||
return false; | ||
} | ||
|
||
AdmissionDate otherAdmissionDate = (AdmissionDate) other; | ||
return value.equals(otherAdmissionDate.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,56 @@ | ||
package seedu.address.model.person; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents a patient's date of birth in the address book. | ||
*/ | ||
public class Dob { | ||
public static final String MESSAGE_CONSTRAINTS = "Dates of birth takes in a date"; | ||
public static final String VALIDATION_REGEX = "^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/[0-9]{4}$"; | ||
|
||
public final String value; | ||
|
||
/** | ||
* Constructs a {@code Dob}. | ||
* | ||
* @param value A valid date of birth. | ||
*/ | ||
public Dob(String value) { | ||
requireNonNull(value); | ||
checkArgument(isValidDob(value), MESSAGE_CONSTRAINTS); | ||
this.value = value; | ||
} | ||
|
||
public static boolean isValidDob(String dob) { | ||
return dob.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
if (!(other instanceof Dob)) { | ||
return false; | ||
} | ||
|
||
Dob otherDob = (Dob) other; | ||
return value.equals(otherDob.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
} | ||
|
||
// Todo: isValidDob | ||
|
||
} |
Oops, something went wrong.