{list here sources of all reused/adapted ideas, code, documentation, and third-party libraries – include links to the original source as well}
Overview
The Storage
class is responsible for managing the saving and loading of Course and Study Session to and from the
local machine. NUStudy will load the saved data from the saved txt file if present when starting the application, and
saving all data back to the saved txt file when application exits.
Implementation Details
The Storage component consists of the following key classes:
Storage
- Main class that handles file I/O operations for saving and loading dataCourse
- Represent a course with a name, provides serialisation via toStorageString()
Session
- Represents a study session linked to a course with logged hours, provides serialisation via
toStorageString()
CourseManager
- Manages the collection of coursesSessionManager
- Manages the collection of study sessionsThe class diagram below illustrates the relationships between these classes:
File format and conventions
Storage
creates a NUStudy.txt
in the directory ./data
when the application first run and performs a save
operation. Subsequent runs of the application will load data from this file.
The storage file is lined-based, with each line representing a single record:
Format
C|<courseName>
S|<courseName>|<loggedHours>
Where:
C|
prefix denotes a Course recordS|
prefix denotes a Session record|
<courseName>
is the course identifier<loggedHours>
is an integer representing study hoursExamples
C|CS2113
C|MA1508E
S|CS2113|2
S|CS2113|5
S|MA1508E|6
This example shows:
Save Operation
The following sequence diagram illustrates how data is stored to storage:
Load Operation
The following sequence diagram illustrates how data is loaded from storage:
How the load
operation work:
ensureParentDirectoryexists()
checks for the parent file. An error message is logged and returns false
if
non-existent.exists()
on the storage file returns false,
empty dataset is initialised. Else, data is loaded in.nextLine()
. Lines with prefix C|
are parsed as courses with parseCourse
(line)
while lines with prefix S|
are parsed as sessions with parseSession(line)
.CourseManager
instance.CourseManager
and SessionManager
instances respectively.Overview
The Reset Functionality enables users to clear logged study hours for either all or a specified course. A double confirmation flow is developed to prevent any unintended and thus, accidental deletions.
Implementation details
y
or n
regardless of capitalisation. This prompt loops until valid input is receivedn
is received, reset operation is cancelledsafeword
- RESET ALL
for all courses and RESET
for a specific coursesafeword
must strictly be equivalent, else reset operation is cancelledReset Workflow
The following activity diagram illustrates the complete reset workflow:
Design Considerations
Aspect: Confirmation mechanism
safeword
reset all
usage{more aspects and alternatives to be added}
{Describe the target user profile}
{Describe the value proposition: what problem does it solve?}
Version | As a … | I want to … | So that I can … |
---|---|---|---|
v1.0 | new user | see usage instructions | refer to them when I forget how to use the application |
v2.0 | user | find a to-do item by name | locate a to-do without having to go through the entire list |
{Give non-functional requirements}
{Give instructions on how to do a manual product testing e.g., how to load sample data to be used for testing}