Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Geinzit committed Apr 11, 2024
2 parents 6ab24d6 + ff00bb3 commit 0ec7acd
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 4 deletions.
13 changes: 13 additions & 0 deletions docs/team/yzhanglp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Yuhao ZHANG

## Overview of `MathGenius`
**`MathGenius`** is a user-friendly application that provides a platform to enhance your equation-solving abilities. Whether you're a student learning calculation, a math enthusiast looking to sharpen your skills, or a teacher preparing for exams/lessons, this application is here to support you.

## Summary of Contribution
[**link to the code**](https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=yzhanglp&breakdown=true)
In the project `MathGenius`, I am in conduct of implement the `checker` part, which is use to check the user's answer, record the time and accuracy, as well as generate the explanation of the questions.
In the `UserGuide`,I am in conduct of writing the introduction and some parts of the guidance.
In the `Development Guide`, I am in conduct of writing the `checker` part as well as draft the DG and draw the UML sequence model.
Of the team based tasks, I am in conduct of setting up the `github repo` and `github team`, release management and conduct meeting.
Basicly, all of us review our PR together, so we all share equal contribution in reviewing PRs. I have helped one of my teammates in setting up the ssh connection of github to make sure she can push the code to the origin.
For other contribution, I am in conduct of arrange the team meeting and gathering to help us stay togther in working out the problems we may meet.
10 changes: 10 additions & 0 deletions recordList.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
2024-04-10 15:14:24 0.05917159763313609 0.2 1131087689 83/9,9.222222222222221 18+0,18.0 16-16,0.0 68/4,17.0 4+61,65.0 30/8,3.75 78+53,131.0 92-22,70.0 51/7,7.285714285714286 28/7,4.0
2024-04-10 15:17:12 0.23255813953488372 0.0 -2045770529 6/4,1.5 68-46,22.0 35/1,35.0 71*76,5396.0 48+6,54.0 23/9,2.5555555555555554 60*98,5880.0 85*10,850.0 88*6,528.0 89+37,126.0
2024-04-10 15:17:28 0.6666666666666666 0.0 1314322124 51-6,45.0 68*42,2856.0 78+55,133.0 97-41,56.0 89-68,21.0 50/7,7.142857142857143 19*64,1216.0 31*57,1767.0 34*75,2550.0 4*71,284.0
2024-04-10 15:19:18 0.11494252873563218 0.0 308676570 6-12,-6.0 44-56,-12.0 68-98,-30.0 73-60,13.0 13-86,-73.0 36-14,22.0 81+13,94.0 74+46,120.0 51*82,4182.0 90-61,29.0
2024-04-10 15:20:47 0.14925373134328357 0.0 -2045770529 43-85,-42.0 86/7,12.285714285714286 67-9,58.0 46*21,966.0 98-69,29.0 72/5,14.4 16*41,656.0 34/3,11.333333333333334 7/9,0.7777777777777778 67+30,97.0
2024-04-10 15:23:41 0.06289308176100629 0.0 -2045770529 91-67,24.0 64+45,109.0 79-50,29.0 50*86,4300.0 85*50,4250.0 31/5,6.2 70*11,770.0 41/9,4.555555555555555 16-47,-31.0 69+88,157.0
2024-04-10 15:34:58 0.01524390243902439 0.0 -585014801 49+52,101.0 37+62,99.0 16+32,48.0 58+58,116.0 82-61,21.0 13+16,29.0 46/7,6.571428571428571 35*27,945.0 64+83,147.0 88/4,22.0
2024-04-10 15:37:53 0.11764705882352941 0.0 854452107 75-65,10.0 17/4,4.25 3/4,0.75 57/8,7.125 84*38,3192.0 79*92,7268.0 45+21,66.0 45*5,225.0 61-89,-28.0 62+68,130.0
2024-04-10 16:08:33 0.29411764705882354 0.4 1784552838 36+17,53.0 19+13,32.0 49/2,24.5 28+16,44.0 76+32,108.0 25*22,550.0 34+42,76.0 28-94,-66.0 0-72,-72.0 96/7,13.714285714285714
2024-04-10 16:19:08 0.20833333333333334 0.3 1784552838 53/6,8.833333333333334 1-71,-70.0 78-57,21.0 75-54,21.0 15/2,7.5 6+59,65.0 57+81,138.0 56+2,58.0 7-49,-42.0 33+87,120.0
82 changes: 78 additions & 4 deletions src/main/java/seedu/duke/Checker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import java.util.List;

public class Checker {
private String[] userAnswer;
private final String[] userAnswer;
private final Test test;
private Boolean[] isCorrect;
private final Boolean[] isCorrect;
private int correctNumber;
private double accuracy;
private long time;
private final List<Problem> wrongProblem = new ArrayList<>();
private List<String> wrongAnswer = new ArrayList<>();
private Ui ui = new Ui("");
private final List<String> wrongAnswer = new ArrayList<>();
private final Ui ui = new Ui("");

public Checker(Test test) {
assert test != null : "Input null test!";
Expand Down Expand Up @@ -60,6 +60,7 @@ void getUserAnswer() {
// hand with time and acc
long endTime = System.currentTimeMillis();
accuracy = (double) correctNumber / test.getNumber();
//millisecond to second
this.time = (endTime - startTime) / 1000;
for (int i = 0; i < test.getNumber(); i++) {
if (isCorrect[i] = false) {
Expand Down Expand Up @@ -92,4 +93,77 @@ public double getAccuracy() {
public long getTime() {
return time;
}

public static String getExplanation(Problem problem){
String description = problem.getDescription();
String start = "Let's explain this problem by the following format: "+"\n\n";
List<String> explanation = new ArrayList<>();
StringBuilder builder = new StringBuilder();
if(description.contains("+")){
String [] parser = description.split("\\+");
double firstNumber = Double.parseDouble(parser[0]);
double secondNumber = Double.parseDouble(parser[1]);
String answerString = String.valueOf(problem.getAnswer());
String firstString = String.valueOf(firstNumber);
String secondString = String.valueOf(secondNumber);
//Shift the longer number to the first
if(firstString.length()<secondString.length()){
String temp = firstString;
firstString = secondString;
secondString = temp;
}
explanation.add(firstString);
explanation.add("+"+" "+secondString);

} else if (description.contains("-")) {
String [] parser = description.split("-");
double firstNumber = Double.parseDouble(parser[0]);
double secondNumber = Double.parseDouble(parser[1]);
String answerString = String.valueOf(problem.getAnswer());
String firstString = String.valueOf(firstNumber);
String secondString = String.valueOf(secondNumber);
//Shift the longer number to the first
if(firstString.length()<secondString.length()){
String temp = firstString;
firstString = secondString;
secondString = temp;
}
explanation.add(firstString);
explanation.add("-"+" "+secondString);

} else if (description.contains("*")){
String [] parser = description.split("\\*");
double firstNumber = Double.parseDouble(parser[0]);
double secondNumber = Double.parseDouble(parser[1]);
String answerString = String.valueOf(problem.getAnswer());
String firstString = String.valueOf(firstNumber);
String secondString = String.valueOf(secondNumber);
//Shift the longer number to the first
if(firstString.length()<secondString.length()){
String temp = firstString;
firstString = secondString;
secondString = temp;
}
explanation.add(firstString);
explanation.add("X"+" "+secondString);

} else if (description.contains("/")){
return "We do not support the explanation with division now!";
}else {
return "The format of the problem do not provide any explanation now!";
}
explanation.add("---------------------------------------" );
explanation.add(String.valueOf(problem.getAnswer()));
for (String element : explanation) {
builder.append(String.format("%" + 20 + "s%n", element));
}
String alignedProblem = builder.toString();
String end = "You can compare your answer with the above function\n";
return start + alignedProblem + "\n" + end;
};
public static void testExplanation() {
Problem testProblem = new Problem("99+9", 108);
System.out.println(getExplanation(testProblem));
}

}
5 changes: 5 additions & 0 deletions src/main/java/seedu/duke/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public static void solveProbSet(Test test, Ui ui, boolean retry, int id) {
Problem problem = wrongProblem.get(i);
ui.print("Your answer: " + problem.getDescription() + " = " + wrongAnswer.get(i));
ui.print("Correct Answer: " + problem.solved());
// need further implementation for 3 more operators
// ui.print("If you want to see the explanation, type exp or explanation, else just type enter");
// String userInput = ui.readCommand();
// if(userInput.equals("exp")||userInput.equals("explanation"))
// System.out.println(Checker.getExplanation(problem));
}

// Storage write to file
Expand Down

0 comments on commit 0ec7acd

Please sign in to comment.