Developer Guide

  1. Design
  2. Implementation
    2.1. Subject Feature
    2.2. Quiz Feature
    2.3. Score Feature
    2.4. Event Management Feature
    2.5. Save/Load Feature
  3. Appendices

1. Design

Architecture


Architecture Diagram
Figure 1. Architecture Diagram

The Duke class is the main class of the product. It is responsible for:

The product also contains the following components:

In these components, cards, subjects and events have similar structure. All of them contain a Card/Subject/Event class and CardList/SubjectList/EventList class. Duke, along with all command classes and Parser, form the Logic box of the product.

Logic Class Diagram
Figure 2. Class diagram of Logic component

The flow of the Logic component is as follows: 1) Duke uses the Parser class to parse the command. 2) The corresponding Command object is created and passed to Duke. 3) The Command object is then executed by Duke.

Command Sequence Diagram
Figure 3. Sequence diagram of Logic component


The Logic box interacts with Model box, i.e. Card, CardList, Subject, SubjectList, Event, EventList, ScoreList.

Model Class Diagram
Figure 4. Class diagram of Model component


Finally, the Storage box, i.e. Storage class will handle reading and writing of the contents to a file.
The Storage component saves and loads the SubjectList objects using the Serializable interface.

Storage Class Diagram
Figure 5. Class diagram of Storage component

2. Implementation

2.1. Subject Feature

2.1.1. Proposed Implementation

The subject feature is an extension to the existing flashcard feature, which allows users to categorise their flashcards. This helps users to search for their flashcards more efficiently and also users to quiz by subject. The list of user’s subjects are stored inside the SubjectList. It implements the following operations:

Step 1. Before the user decides to add a flashcard, he/she must first create a subject to store the flashcard, using the command addsubject s/SUBJECTNAME. The following diagram describes how the add subject operation works:


Addsubject Sequence Diagram
Figure 6. Sequence diagram for 'addsubject' command

Step 2. The user executes the command listsubject to view the subjects currently stored in the application.

Step 3. Once the user has decided on a subject, he/she can execute the command addcard s/SUBJECTINDEX q/QUESTION a/ANSWER to add a flashcard into the subject.

The following diagram describes how the add card operation works:

Addcard Sequence Diagram
Figure 7. Sequence diagram of 'addcard' command.

2.1.2. Design Considerations

Aspect: How a user can add a flashcard into a subject

2.2. Quiz Feature

2.2.1. Implementation

The quiz feature incorporates random testing, and builds upon the subject feature to allow users to set how many questions to quiz for a selected subject. This allows users to quiz by subject, and get a score at the end of each quiz.

As of the current version, the quiz feature does not support automatic marking, and the user will have to mark their own answers for each question. Automatic marking may be added in future versions.

The quiz feature implements the following operations:

Given below is an example usage scenario and how the quiz mechanism behaves at each step.

Step 1. Before the user decides to start a quiz, he/she has to create a subject using the command addsubject s/SUBJECTNAME, and add flashcards to that subject using the command addcard s/SUBJECTINDEX q/QUESTION a/ANSWER.

Step 2. The user can start a quiz by indicating a subject and the number of questions to quiz using the command quiz s/SUBJECTINDEX n/NUMBERTOQUIZ. If the number of questions to quiz is not specified (e.g. if quiz s/SUBJECTINDEX is entered) , all the questions stored in that subject will be quizzed.

The following diagram describes how the quiz operation works:


Quiz Sequence Diagram
Figure 8. Sequence diagram of 'quiz' command.

Step 3: The quiz will end upon completion of the specified number of questions, or by stopping the quiz using the command exitquiz.

2.2.2. Design Considerations

Aspect: How the answers are marked for correctness
Aspect: How the user can control how many questions to be quizzed

2.3. Score Feature

2.3.1. Implementation

The score feature builds on the quiz feature, storing the score for each quiz session in a ScoreList. This allows users to see all past scores and track any improvements. It implements the following operations:

Given below is an example usage scenario and how the score mechanism behaves at each step.

Step 1. Before the user can view his scores for a particular subject, he first needs to have done at least one quiz session for that subject using the command quiz s/SUBJECTINDEX n/NUMBERTOQUIZ.

Step 2. The user can view the score history and average score of a selected subject, if he has done at least one quiz session for that subject, using the command score s/SUBJECTINDEX.

The following diagram describes how the score operation works:


Score Sequence Diagram
Figure 9. Sequence diagram of 'score' command

2.3.2. Design Considerations

Aspect: How to format the score history shown to the user

2.4. Event Management Feature

2.4.1 Implementation

The event feature builds on the program feature by aiding the user when preparing for an exam or keeping track of events. This feature allows the user to add and keep track of upcoming events, such as exams/tests. It implements the following operations:

Given below is an example usage scenario and how the event mechanism behaves at each step.

Step 1. Before the user can manage his/her events, he/she needs to first add events using the command addevent e/DESCRIPTION d/DATE.

The following diagram describes how the add event operation works:


Addevent Sequence Diagram
Figure 10. Sequence diagram of 'addevent' command

Step 2. The user executes the command listevent to view the events currently stored in the application.

Step 3. The user can then execute the command showupcoming d/DAYS to show events that are upcoming within DAYS number of days.

The following diagram describes how the show upcoming operation works:


Showupcoming Sequence Diagram
Figure 11. Sequence diagram of 'showupcoming' command

2.4.2. Design Considerations

Aspect: How to implement addition and management of events

2.5. Save/Load Feature

2.5.1 Implementation

The save/load process is facilitated with the java.io.Serializable interface, which converts the given object to a byte stream and back. Writing and reading from the file uses the java.io.FileOutputStream and java.io.FileInputStream classes respectively.

The choice of the java.io.Serializable interface as a save/load function is because it maintains the object structure. In addition, the implementation of the interface is easy and simple to understand as does not require much code, and does not require manipulation of raw data. This ensures that it is easy to modify the Storage methods if other elements/objects are added to the structure.

To serialize the object to be written to file via java.io.FileOutputStream, it makes use of the java.io.ObjectOutputStream#writeObject method. To deserialize the object after being read from file via java.io.FileInputStream, it uses the java.io.ObjectInputStream#readObject() method.

The Storage feature implements the following operations:

Storage#loadSubs() is run on initialisation of the program. It first checks if there is a preexisting saved file:

Storage#saveSubs() is run after every command execution. This ensures that if the program is force-exited or suddenly crashes, the last instruction has been saved. Once run, it will first check if the save file exists, in the event that the file has been deleted during the program. If so, it will create the file, then the method will continue on to save the latest SubjectList structure into the save file.


Storage Sequence Diagram
Figure 12. Sequence diagram of Storage class

3. Appendices

Appendix A: Product Scope

Target User Profile

The product is intended for students preparing for exams. Students can store practice question and model answers in the product. Also, the product offers students to quiz themselves to practice for exams.

Value Proposition

The product aims to provide students with more convenient way of doing revision. By using the product students can categorize questions into different subjects and practice more effectively. As such, in release v2.1, after adding the cards the user is unable to view the answers when listing cards. This feature may be improved on in later releases.

Appendix B: User Stories

Version As a … I want to … So that I can …
v1.0 user add new cards view cards and answers to revise
v1.0 user delete cards organize cards better
v1.0 user quiz myself practice the questions
v1.0 user list cards organize the cards
v1.0 user save my cards access them in the future
v2.0 user add cards with subjects categorize the cards better
v2.0 user list cards by subjects organize the cards
v2.0 user delete subjects organize subjects better
v2.0 user view my score see how I performed
v2.0 user view my test history see how I performed
v2.1 user add upcoming event dates know what to prepare
v2.1 user delete upcoming event dates no longer have reminders of the events
v2.1 user edit the cards change the mistakes done when adding

Appendix C: Non-Functional Requirements

  1. The product should be able to run on any platform that has JDK11
  2. The product should be able to hold up to 1000 cards
  3. The product should be able to store up to 1000 events

Appendix D: Instructions for Manual Testing

Running Tests

Method : Using IntelliJ JUnit test runner

Method : Using the text-ui-test runtest.bat or runtest.sh script

Types of Tests

There have two types of tests:

Unit tests targeting the lowest level methods/classes.

Integration tests that are checking the integration of multiple code units (those code units are assumed to be working).