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

changed questions and added increasing difficulty functionality #98

Merged
merged 1 commit into from
Apr 8, 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
5 changes: 3 additions & 2 deletions src/main/java/map/BattleInterface/BattleInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public void enableFight(Scanner in) {
MathPool mathPool = new MathPool();
mathPool.init();
Ui ui = new Ui();

int difficulty = 0;
while (currentPlayer.getPlayerHealth() > 0 && currentEntity.getHealth() > 0) {
int answer;
Pattern pattern = Pattern.compile("^[--]?[0-9]+$");
ui.printPlayerStatus(currentPlayer);
ui.printMap(mapData, (Enemy) currentEntity);
MathQuestion mathQuestion = mathPool.getQuestionByDifficulty(0);
MathQuestion mathQuestion = mathPool.getQuestionByDifficulty(difficulty);
//ui.printQuestion(mathQuestion);
currentTextBox.setNextNarration(mathQuestion.getQuestion());
ui.printTextBox(currentTextBox);
Expand All @@ -59,6 +59,7 @@ public void enableFight(Scanner in) {
+ " can");

playerHitEnemy();
difficulty += 1;
} else {
currentTextBox.setNextDialogue("You got the question WRONG. The enemy proceeds to attack you.");
enemyHitPlayer();
Expand Down
64 changes: 37 additions & 27 deletions src/main/java/math/MathPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,39 +56,49 @@ public MathQuestion getQuestionByDifficulty(int targetDifficulty) {


public void init() {
// Difficulty 0
addMathQuestion("1 + 1 = ", 2, 0);
addMathQuestion("1 + 2 = ", 3, 0);
addMathQuestion("3 + 1 = ", 4, 0);
addMathQuestion("2 + 5 = ", 7, 0);
addMathQuestion("10 + 23 = ", 33, 0);

// Difficulty 1
addMathQuestion("5 - 3 = ", 2, 1);
addMathQuestion("8 + 4 = ", 12, 1);
addMathQuestion("10 - 6 = ", 4, 1);
addMathQuestion("7 + 6 = ", 13, 1);
addMathQuestion("9 - 2 = ", 7, 1);


// Difficulty 2
addMathQuestion("6 * 4 = ", 24, 2);
addMathQuestion("12 / 3 = ", 4, 2);
addMathQuestion("9 * 5 = ", 45, 2);
addMathQuestion("20 / 4 = ", 5, 2);
addMathQuestion("8 * 7 = ", 56, 2);
addMathQuestion("6 * 4 = ", 24, 0);
addMathQuestion("12 / 3 = ", 4, 0);
addMathQuestion("9 * 5 = ", 45, 0);
addMathQuestion("20 / 4 = ", 5, 0);
addMathQuestion("8 * 7 = ", 56, 0);

// Difficulty 3
addMathQuestion("5^2 = ", 25, 3);
addMathQuestion("square root of 144 = ", 12, 3);
addMathQuestion("3^3 = ", 27, 3);
addMathQuestion("square root of 81 = ", 9, 3);
addMathQuestion("7^2 = ", 49, 3);
addMathQuestion("5^2 = ", 25, 1);
addMathQuestion("square root of 144 = ", 12, 1);
addMathQuestion("3^3 = ", 27, 1);
addMathQuestion("square root of 81 = ", 9, 1);
addMathQuestion("7^2 = ", 49, 1);

// Difficulty 4
addMathQuestion("What is the sum of all angles in a triangle?", 180, 4);
addMathQuestion("How many sides does a hexagon have?", 6, 4);
addMathQuestion("What is the area of a square with side length 5?", 25, 4);
addMathQuestion("What is the perimeter of a rectangle with sides 4 and 6?", 20, 4);
addMathQuestion("What is the sum of all angles in a triangle?", 180, 2);
addMathQuestion("How many sides does a hexagon have?", 6, 2);
addMathQuestion("What is the area of a square with side length 5?", 25, 2);
addMathQuestion("What is the perimeter of a rectangle with sides 4 and 6?", 20, 2);
// Difficulty 3
addMathQuestion("What is 2 times the square root of 64?", 16, 3);
addMathQuestion("How many degrees are in a right angle?", 90, 3);
addMathQuestion("If a square has an area of 25 square units, what is the length of one side?", 5, 3);
addMathQuestion("What is the sum of the first 10 positive integers?", 55, 3);
addMathQuestion("How many edges does a cube have?", 12, 3);

// Difficulty 4
addMathQuestion("What is the value of 5 factorial (5!)?", 120, 4);
addMathQuestion("What is the next prime number after 31?", 37, 4);
addMathQuestion("How many vertices does a tetrahedron have?", 4, 4);
addMathQuestion("How many diagonals does a hexagon have?", 9, 4);
addMathQuestion("How many millimeters are in a meter?", 1000, 4);

// Difficulty 5
addMathQuestion("What is the value of 7 choose 3 (7C3)?", 35, 5);
addMathQuestion("How many faces does a dodecahedron have?", 12, 5);
addMathQuestion("How many sides does a regular polygon have if each exterior angle measures 30 degrees?", 12, 5);
addMathQuestion("What is the 20th Fibonacci number?", 6765, 5);
addMathQuestion("What is the value of 2^10?", 1024, 5);


}

}
1 change: 1 addition & 0 deletions tp
Submodule tp added at c09c89
Loading