Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete useless files. update DG and README.md #113

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 101 additions & 35 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ We would also like to thank all the developers and contributors of these project


### ProblemGenerator Component
API: [ProblemGenerator.java](../src/main/java/seedu/duke/ProblemGenerator.java)
API: [ProblemGenerator.java](https://github.com/AY2324S2-CS2113-T13-1/tp/tree/master/src/main/java/seedu/duke/ProblemGenerator.java)

The `ProblemGenerator` component is designed to generate a set of math problems based on user-specified parameters.

Expand All @@ -81,7 +81,7 @@ The `Calculator` class calculates the answer to each problem during problem gene


### Checker Component
**API:[Checker.java](../src/main/java/seedu/duke/Checker.java)**
**API:[Checker.java](https://github.com/AY2324S2-CS2113-T13-1/tp/tree/master/src/main/java/seedu/duke/Checker.java)**

#### How `Checker` Works:
1. Each `Checker` instance is created with a `Test` class.
Expand Down Expand Up @@ -118,25 +118,46 @@ for problem in problem set:

### Record Component

API: [Record.java](../src/main/java/seedu/duke/Record.java)
API: [Record.java](https://github.com/AY2324S2-CS2113-T13-1/tp/tree/master/src/main/java/seedu/duke/Record.java)

#### Design

The `Record` component is a snapshot of completed problem sets. It includes:

- Individual `Problem` instances
- The date the problem set was solved (`dateTime`)
- The time taken to solve the problem set (`speed`)
- The accuracy of the attempt (`accuracy`)
- Individual problems(each problem includes its description and a specific answer)
- The date the problem set was solved
- The time taken to solve the problem set
- The accuracy of the attempt
- a unique ID for the problem set, its function and purpose is explained below
- a special type indicator of the problem set, can be 'user-DIY' or 'auto-generated', details are explained below

Each `Record` also stores the specifics of each `Problem` and a unique ID (created using Java's default `hashCode`) for organized or filtered viewing of past records.
*Unique ID*:

Users can choose whether to display the problem set specifics or not using the `showProbDetails` parameter.
Each `Record` also stores the specifics of each problem and a unique ID (created using Java's default `hashCode`) for organized or filtered viewing of past records. The ID also serves as an index for users to reference when they wish to try a past problem set

When writing a `Record` to an external file, it's written into a single line in the format of "`/dateTime(format:yyyy-MM-dd HH:mm:ss) /speed /accuracy /problemSetID /problems`". For problems, each `Problem` is separated by a space and is formatted in "/problemDescription,/problemAnswer".

The unique ID for problem sets can be used in the `retry` command to uniquely locate any problem set for the users to retry a previous problem set.

*Problem Set Type*

Since the application supports user-entered problem sets, each record will remember if the problem set is generated by program or user-entered.

- 'user-DIY' means this problem is user-generated
- 'auto-generated' means this problem is program-generated via command `generate`

*Displaying a Record*

Considering if problem sets having large number of problem could result in cumbersome viewing when all problems in the problem set is displayed, the `records` command provides a parameter to customize this.

Users can choose whether to display the problem set specifics or not using the `showProbDetails` parameter.

Also, when users first created a problem set, the DIYProblemSet component will create a dummy record(as in no users actually answered this problem set) with a speed 0. All dummy records will have different display format to inform users that this is a DIY problem set record.


*Saving Record to file*

When writing a record to an external file, it's written into a single line in the format of "/dateTime(format:yyyy-MM-dd HH:mm:ss) /speed /accuracy /problemSetID /problems". For problems, each problem is separated by a space and is formatted in "/problemDescription,/problemAnswer".

#### Implementation

- Each `Record` object stores an `ArrayList` of `Problem` objects for storing specifics of the attempted Problem Set.
Expand All @@ -145,28 +166,71 @@ The unique ID for problem sets can be used in the `retry` command to uniquely lo

- Another purpose for the two different constructors: the first one does not include a preset problem set ID as an argument. This is used when the problem set the users solved is done through the `generate` command. Each generated problem set will automatically be assigned a random hashcode as its ID. The second one does contain a problem set ID as an argument, and this is for when the user uses the `retry` command to retry a past problem set in the records. Thus, the new `Record` should use the same ID as the last, since it's the same problem set..

**Code Snippet**
*Code Snippet*
```
// the two different constructors
public Record(LocalDateTime dateTime, double speed, double accuracy, ArrayList<Problem> probSet) {
setSpeed(speed);
setAccuracy(accuracy);
setDateTime(dateTime);
setProbSet(probSet);
psIndex = probSet.hashCode();
public Record(LocalDateTime dateTime,
double speed,
double accuracy,
ArrayList<Problem> probSet,
String problemSetType) {
setSpeed(speed);
setAccuracy(accuracy);
setDateTime(dateTime);
setProbSet(probSet);
setProblemSetType(problemSetType);
psIndex = probSet.hashCode();
}

public Record(LocalDateTime dateTime, double speed, double accuracy, ArrayList<Problem> probSet, int psIndex) {
setSpeed(speed);
setAccuracy(accuracy);
setDateTime(dateTime);
setProbSet(probSet);
setPsIndex(psIndex);
public Record(LocalDateTime dateTime,
double speed,
double accuracy,
ArrayList<Problem> probSet,
int psIndex,
String problemSetType) {
setSpeed(speed);
setAccuracy(accuracy);
setDateTime(dateTime);
setProbSet(probSet);
setPsIndex(psIndex);
setProblemSetType(problemSetType);
}
```

- When a DIY problem set is saved in the records, the speed value is set as 0. And this value will be the indicator in the output method of the Record, all saved records will have different output format, since the user didn't actually answer the problem set by creating it.

*Code Snippet*
```
public void print(boolean showProbDetails) {
// ui.printRecords(showProbDetails, this);
if (getSpeed() <= 0.0) {
System.out.println("--User DIY Problem Set--");
System.out.println("ProblemSet ID: " + getPsIndex());
if (showProbDetails) {
for (Problem problem : probSet) {
System.out.println(" " + problem.getDescription());
}
}
} else {
System.out.println("--User Attempt Record--");
System.out.println("Date Time: " + getDateTime().format(formatter));
System.out.println("ProblemSet ID: " + getPsIndex());
if (showProbDetails) {
for (Problem problem : probSet) {
System.out.println(" " + problem.getDescription());
}
}
System.out.println("Speed: " + getSpeed() + " problems per minute");
System.out.println("Accuracy: " + getAccuracy() * 100 + "%");
System.out.println("Problem Set type: " + getProblemSetType());
}
}
```
- the `writeLine` method is for the purpose of writing a record into the external file, please differentiate this method, from the `print` method which is used for conveying information to the user, for information on the format, check the *design* section of `Record`

### Storage Component

API: [`Storage.java`](../src/main/java/seedu/duke/Storage.java)
API: [Storage.java](https://github.com/AY2324S2-CS2113-T13-1/tp/tree/master/src/main/java/seedu/duke/Storage.java)

#### Design

Expand All @@ -177,30 +241,32 @@ The `Storage` Component:
- Incorporates the `UI` and `Parser` components for proper user feedback regarding the save/load process.
- Stores a list of `Record` objects for reading/writing. Each `Record` is stored on a single, separate line. The formatting of each line is explained in the `Record` section.
- The `recordList` can be sorted by multiple parameters, including `dateTime`, `speed`, `accuracy`, and `problemSetID`. This is used by the `UI` component to display users' past records in any order they desire.
- Features a function that takes in a problem set ID and returns a Test object which contains this problem set, to support the command `retry`

#### Implementation

- Uses a list of `Record` objects to store all past attempts.
- Uses Java's built-in `BufferedReader`, `FileReader`, `BufferedWriter`, and `FileWriter` to write/read properly all information of all problem sets.
- `sortRecords` method sorts the `Record` list based on 4 different parameters(each representing sort by `datetime`, `speed`, `accuracy`, `problemSetID`). Each parameter has 3 different values: `0`, `1`, `2`. `0` means to not sort by this parameter, `1` means to sort(decreasing order), `2` means to sort in reverse(increasing order). These 4 parameters are determined by the user input, and interpreted by the `Parser` component.
- `problemSetByID` searches through the Record list, and returns a `Test` object based on the problem set, which is Class used by the program to intiate an user answer sequence via the `Checker` component.

### DIYProblemSet Component

The `DIYProblemSet` class is responsible for creating and managing a user-defined problem set. It allows users to input custom problems and their correct answers, and saves the problem set for future reference.

#### Class Signature
```
public class DIYProblemSet {
ArrayList<Problem> problemSet;
public DIYProblemSet() {
// Constructor logic
}
public void addDIYProblemSet(Ui ui) {
// Method logic
}
}
public class DIYProblemSet {
ArrayList<Problem> problemSet;

public DIYProblemSet() {
// Constructor logic
}

public void addDIYProblemSet(Ui ui) {
// Method logic
}
}
```
#### Class Variables
```
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke
# MathGenius

**MathGenius** is a user-friendly application that provides a platform to enhance your Math equation-solving abilities.

Expand Down
5 changes: 0 additions & 5 deletions docs/heinzhuang.md

This file was deleted.

27 changes: 19 additions & 8 deletions src/main/java/seedu/duke/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,27 @@ public Record(LocalDateTime dateTime,


public void print(boolean showProbDetails) {
System.out.println("Date Time: " + getDateTime().format(formatter));
System.out.println("ProblemSet ID: " + getPsIndex());
if (showProbDetails) {
for (Problem problem : probSet) {
System.out.println(" " + problem.getDescription());
if (getSpeed() <= 0.0) {
System.out.println("--User DIY Problem Set--");
System.out.println("ProblemSet ID: " + getPsIndex());
if (showProbDetails) {
for (Problem problem : probSet) {
System.out.println(" " + problem.getDescription());
}
}
} else {
System.out.println("--User Attempt Record--");
System.out.println("Date Time: " + getDateTime().format(formatter));
System.out.println("ProblemSet ID: " + getPsIndex());
if (showProbDetails) {
for (Problem problem : probSet) {
System.out.println(" " + problem.getDescription());
}
}
System.out.println("Speed: " + getSpeed() + " problems per minute");
System.out.println("Accuracy: " + getAccuracy() * 100 + "%");
System.out.println("Problem Set type: " + getProblemSetType());
}
System.out.println("Speed: " + getSpeed() + " problems per minute");
System.out.println("Accuracy: " + getAccuracy() * 100 + "%");
System.out.println("Problem Set type: " + getProblemSetType());
}

public String writeLine() {
Expand Down
Loading