forked from nus-cs2103-AY2425S1/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 pull request #65 from izruff/add-attendance-support
Integrate attendances with UI and update tests
- Loading branch information
Showing
13 changed files
with
228 additions
and
46 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
35 changes: 35 additions & 0 deletions
35
src/main/java/seedu/address/storage/JsonAdaptedAttendance.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,35 @@ | ||
package seedu.address.storage; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import seedu.address.model.person.Attendance; | ||
|
||
/** | ||
* Jackson-friendly version of {@link Attendance}. | ||
*/ | ||
public class JsonAdaptedAttendance { | ||
|
||
public static final String MISSING_FIELD_MESSAGE_FORMAT = "Attendance's %s field is missing!"; | ||
|
||
private final boolean hasAttended; | ||
|
||
/** | ||
* Constructs a {@code JsonAdaptedAttendance} with the given attendance details. | ||
*/ | ||
@JsonCreator | ||
public JsonAdaptedAttendance(@JsonProperty("hasAttended") boolean hasAttended) { | ||
this.hasAttended = hasAttended; | ||
} | ||
|
||
public JsonAdaptedAttendance(Attendance source) { | ||
hasAttended = source.hasAttended(); | ||
} | ||
|
||
/** | ||
* Converts this Jackson-friendly adapted attendance object into the model's {@code Attendance} object. | ||
*/ | ||
public Attendance toModelType() { | ||
return new Attendance(hasAttended); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,21 +6,31 @@ | |
"email" : "[email protected]", | ||
"address" : "123, Jurong West Ave 6, #08-111", | ||
"tags" : [ "friends" ], | ||
"grades" : [] | ||
"grades" : [], | ||
"attendances": {} | ||
}, { | ||
"name" : "Benson Meier", | ||
"phone" : "98765432", | ||
"email" : "[email protected]", | ||
"address" : "311, Clementi Ave 2, #02-25", | ||
"tags" : [ "owesMoney", "friends" ], | ||
"grades" : [] | ||
"grades" : [], | ||
"attendances": {} | ||
}, { | ||
"name" : "Carl Kurz", | ||
"phone" : "95352563", | ||
"email" : "[email protected]", | ||
"address" : "wall street", | ||
"tags" : [ ], | ||
"grades" : [] | ||
"grades" : [], | ||
"attendances" : { | ||
"2024-01-01T12:00" : { | ||
"hasAttended" : true | ||
}, | ||
"2024-01-08T12:00" : { | ||
"hasAttended" : false | ||
} | ||
} | ||
}, { | ||
"name" : "Daniel Meier", | ||
"phone" : "87652533", | ||
|
@@ -38,7 +48,15 @@ | |
"score": 90, | ||
"weightage": 30 | ||
} | ||
] | ||
], | ||
"attendances" : { | ||
"2024-01-01T12:00" : { | ||
"hasAttended" : true | ||
}, | ||
"2024-01-08T12:00" : { | ||
"hasAttended" : false | ||
} | ||
} | ||
}, { | ||
"name" : "Elle Meyer", | ||
"phone" : "9482224", | ||
|
@@ -56,7 +74,15 @@ | |
"score": 90, | ||
"weightage": 30 | ||
} | ||
] | ||
], | ||
"attendances" : { | ||
"2024-01-01T12:00" : { | ||
"hasAttended" : true | ||
}, | ||
"2024-01-08T12:00" : { | ||
"hasAttended" : false | ||
} | ||
} | ||
}, { | ||
"name" : "Fiona Kunz", | ||
"phone" : "9482427", | ||
|
@@ -74,7 +100,15 @@ | |
"score": 90, | ||
"weightage": 30 | ||
} | ||
] | ||
], | ||
"attendances" : { | ||
"2024-02-14T10:00" : { | ||
"hasAttended" : false | ||
}, | ||
"2024-02-21T10:00" : { | ||
"hasAttended" : true | ||
} | ||
} | ||
}, { | ||
"name" : "George Best", | ||
"phone" : "9482442", | ||
|
@@ -92,6 +126,14 @@ | |
"score": 92, | ||
"weightage": 25 | ||
} | ||
] | ||
], | ||
"attendances" : { | ||
"2024-02-14T10:00" : { | ||
"hasAttended" : false | ||
}, | ||
"2024-02-21T10:00" : { | ||
"hasAttended" : true | ||
} | ||
} | ||
} ] | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/java/seedu/address/storage/JsonAdaptedAttendanceTest.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,18 @@ | ||
package seedu.address.storage; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.person.Attendance; | ||
|
||
public class JsonAdaptedAttendanceTest { | ||
private static final Attendance VALID_ATTENDANCE = new Attendance(true); | ||
private static final boolean VALID_HAS_ATTENDED = true; | ||
|
||
@Test | ||
public void toModelType_validAttendanceDetails_returnAttendance() { | ||
JsonAdaptedAttendance attendance = new JsonAdaptedAttendance(VALID_HAS_ATTENDED); | ||
assertEquals(VALID_ATTENDANCE, attendance.toModelType()); | ||
} | ||
} |
Oops, something went wrong.