From 774caa344ac65cace97c7b31248b531a1b8f1f4a Mon Sep 17 00:00:00 2001 From: mcsoula Date: Sun, 21 Jan 2018 15:02:16 -0500 Subject: [PATCH] Alexander Feng , Submitting math game. --- .idea/misc.xml | 2 +- .idea/modules.xml | 1 - .idea/vcs.xml | 2 +- .../android_arch_core_common_1_0_0_jar.xml | 11 ++ ...ndroid_arch_lifecycle_common_1_0_0_jar.xml | 11 ++ .../android_arch_lifecycle_runtime_1_0_0.xml | 12 ++ ...upport_animated_vector_drawable_26_1_0.xml | 12 ++ ...om_android_support_appcompat_v7_26_1_0.xml | 12 ++ ...ort_constraint_constraint_layout_1_0_2.xml | 10 ++ ...int_constraint_layout_solver_1_0_2_jar.xml | 9 ++ ...support_support_annotations_26_1_0_jar.xml | 11 ++ ..._android_support_support_compat_26_1_0.xml | 12 ++ ...android_support_support_core_ui_26_1_0.xml | 12 ++ ...roid_support_support_core_utils_26_1_0.xml | 12 ++ ...ndroid_support_support_fragment_26_1_0.xml | 12 ++ ...id_support_support_media_compat_26_1_0.xml | 12 ++ .../com_android_support_support_v4_26_1_0.xml | 12 ++ ...support_support_vector_drawable_26_1_0.xml | 12 ++ ...port_test_espresso_espresso_core_3_0_1.xml | 12 ++ ...spresso_espresso_idling_resource_3_0_1.xml | 12 ++ .../com_android_support_test_rules_1_0_1.xml | 12 ++ .../com_android_support_test_runner_1_0_1.xml | 12 ++ ..._google_code_findbugs_jsr305_2_0_1_jar.xml | 9 ++ .../com_squareup_javawriter_2_1_1_jar.xml | 11 ++ .../javax_inject_javax_inject_1_jar.xml | 11 ++ app/.idea/libraries/junit_junit_4_12_jar.xml | 11 ++ .../libraries/net_sf_kxml_kxml2_2_3_0_jar.xml | 9 ++ .../org_hamcrest_hamcrest_core_1_3_jar.xml | 11 ++ ..._hamcrest_hamcrest_integration_1_3_jar.xml | 11 ++ .../org_hamcrest_hamcrest_library_1_3_jar.xml | 11 ++ app/.idea/modules.xml | 9 ++ app/.idea/vcs.xml | 6 + app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 9 +- .../com/strobertchs/cs/mathgame/Game.java | 59 -------- .../strobertchs/cs/mathgame/GameActivity.java | 138 ------------------ .../strobertchs/cs/mathgame/MainActivity.java | 31 ---- .../com/strobertchs/cs/mathgame/Question.java | 93 ------------ app/src/main/res/layout/activity_game.xml | 86 ++++++----- app/src/main/res/layout/activity_main.xml | 60 -------- app/src/main/res/values/strings.xml | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 42 files changed, 372 insertions(+), 436 deletions(-) create mode 100644 app/.idea/libraries/android_arch_core_common_1_0_0_jar.xml create mode 100644 app/.idea/libraries/android_arch_lifecycle_common_1_0_0_jar.xml create mode 100644 app/.idea/libraries/android_arch_lifecycle_runtime_1_0_0.xml create mode 100644 app/.idea/libraries/com_android_support_animated_vector_drawable_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_appcompat_v7_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_constraint_constraint_layout_1_0_2.xml create mode 100644 app/.idea/libraries/com_android_support_constraint_constraint_layout_solver_1_0_2_jar.xml create mode 100644 app/.idea/libraries/com_android_support_support_annotations_26_1_0_jar.xml create mode 100644 app/.idea/libraries/com_android_support_support_compat_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_support_core_ui_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_support_core_utils_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_support_fragment_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_support_media_compat_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_support_v4_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_support_vector_drawable_26_1_0.xml create mode 100644 app/.idea/libraries/com_android_support_test_espresso_espresso_core_3_0_1.xml create mode 100644 app/.idea/libraries/com_android_support_test_espresso_espresso_idling_resource_3_0_1.xml create mode 100644 app/.idea/libraries/com_android_support_test_rules_1_0_1.xml create mode 100644 app/.idea/libraries/com_android_support_test_runner_1_0_1.xml create mode 100644 app/.idea/libraries/com_google_code_findbugs_jsr305_2_0_1_jar.xml create mode 100644 app/.idea/libraries/com_squareup_javawriter_2_1_1_jar.xml create mode 100644 app/.idea/libraries/javax_inject_javax_inject_1_jar.xml create mode 100644 app/.idea/libraries/junit_junit_4_12_jar.xml create mode 100644 app/.idea/libraries/net_sf_kxml_kxml2_2_3_0_jar.xml create mode 100644 app/.idea/libraries/org_hamcrest_hamcrest_core_1_3_jar.xml create mode 100644 app/.idea/libraries/org_hamcrest_hamcrest_integration_1_3_jar.xml create mode 100644 app/.idea/libraries/org_hamcrest_hamcrest_library_1_3_jar.xml create mode 100644 app/.idea/modules.xml create mode 100644 app/.idea/vcs.xml delete mode 100644 app/src/main/java/com/strobertchs/cs/mathgame/Game.java delete mode 100644 app/src/main/java/com/strobertchs/cs/mathgame/GameActivity.java delete mode 100644 app/src/main/java/com/strobertchs/cs/mathgame/MainActivity.java delete mode 100644 app/src/main/java/com/strobertchs/cs/mathgame/Question.java delete mode 100644 app/src/main/res/layout/activity_main.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 635999d..3963879 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 8aecf06..4c84464 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,6 @@ - diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1dd..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/.idea/libraries/android_arch_core_common_1_0_0_jar.xml b/app/.idea/libraries/android_arch_core_common_1_0_0_jar.xml new file mode 100644 index 0000000..ee12c7f --- /dev/null +++ b/app/.idea/libraries/android_arch_core_common_1_0_0_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/android_arch_lifecycle_common_1_0_0_jar.xml b/app/.idea/libraries/android_arch_lifecycle_common_1_0_0_jar.xml new file mode 100644 index 0000000..66e22be --- /dev/null +++ b/app/.idea/libraries/android_arch_lifecycle_common_1_0_0_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/android_arch_lifecycle_runtime_1_0_0.xml b/app/.idea/libraries/android_arch_lifecycle_runtime_1_0_0.xml new file mode 100644 index 0000000..3f02db4 --- /dev/null +++ b/app/.idea/libraries/android_arch_lifecycle_runtime_1_0_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_animated_vector_drawable_26_1_0.xml b/app/.idea/libraries/com_android_support_animated_vector_drawable_26_1_0.xml new file mode 100644 index 0000000..dc1e971 --- /dev/null +++ b/app/.idea/libraries/com_android_support_animated_vector_drawable_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_appcompat_v7_26_1_0.xml b/app/.idea/libraries/com_android_support_appcompat_v7_26_1_0.xml new file mode 100644 index 0000000..ba10eb0 --- /dev/null +++ b/app/.idea/libraries/com_android_support_appcompat_v7_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_constraint_constraint_layout_1_0_2.xml b/app/.idea/libraries/com_android_support_constraint_constraint_layout_1_0_2.xml new file mode 100644 index 0000000..894ca8b --- /dev/null +++ b/app/.idea/libraries/com_android_support_constraint_constraint_layout_1_0_2.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_constraint_constraint_layout_solver_1_0_2_jar.xml b/app/.idea/libraries/com_android_support_constraint_constraint_layout_solver_1_0_2_jar.xml new file mode 100644 index 0000000..7a05a33 --- /dev/null +++ b/app/.idea/libraries/com_android_support_constraint_constraint_layout_solver_1_0_2_jar.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_support_annotations_26_1_0_jar.xml b/app/.idea/libraries/com_android_support_support_annotations_26_1_0_jar.xml new file mode 100644 index 0000000..c6c1dfa --- /dev/null +++ b/app/.idea/libraries/com_android_support_support_annotations_26_1_0_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_support_compat_26_1_0.xml b/app/.idea/libraries/com_android_support_support_compat_26_1_0.xml new file mode 100644 index 0000000..825d690 --- /dev/null +++ b/app/.idea/libraries/com_android_support_support_compat_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_support_core_ui_26_1_0.xml b/app/.idea/libraries/com_android_support_support_core_ui_26_1_0.xml new file mode 100644 index 0000000..7d3d6de --- /dev/null +++ b/app/.idea/libraries/com_android_support_support_core_ui_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_support_core_utils_26_1_0.xml b/app/.idea/libraries/com_android_support_support_core_utils_26_1_0.xml new file mode 100644 index 0000000..5b24fb8 --- /dev/null +++ b/app/.idea/libraries/com_android_support_support_core_utils_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_support_fragment_26_1_0.xml b/app/.idea/libraries/com_android_support_support_fragment_26_1_0.xml new file mode 100644 index 0000000..2f2be13 --- /dev/null +++ b/app/.idea/libraries/com_android_support_support_fragment_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_support_media_compat_26_1_0.xml b/app/.idea/libraries/com_android_support_support_media_compat_26_1_0.xml new file mode 100644 index 0000000..ac10536 --- /dev/null +++ b/app/.idea/libraries/com_android_support_support_media_compat_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_support_v4_26_1_0.xml b/app/.idea/libraries/com_android_support_support_v4_26_1_0.xml new file mode 100644 index 0000000..03bbd4f --- /dev/null +++ b/app/.idea/libraries/com_android_support_support_v4_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_support_vector_drawable_26_1_0.xml b/app/.idea/libraries/com_android_support_support_vector_drawable_26_1_0.xml new file mode 100644 index 0000000..0a4fb22 --- /dev/null +++ b/app/.idea/libraries/com_android_support_support_vector_drawable_26_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_test_espresso_espresso_core_3_0_1.xml b/app/.idea/libraries/com_android_support_test_espresso_espresso_core_3_0_1.xml new file mode 100644 index 0000000..49608d0 --- /dev/null +++ b/app/.idea/libraries/com_android_support_test_espresso_espresso_core_3_0_1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_test_espresso_espresso_idling_resource_3_0_1.xml b/app/.idea/libraries/com_android_support_test_espresso_espresso_idling_resource_3_0_1.xml new file mode 100644 index 0000000..a22329d --- /dev/null +++ b/app/.idea/libraries/com_android_support_test_espresso_espresso_idling_resource_3_0_1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_test_rules_1_0_1.xml b/app/.idea/libraries/com_android_support_test_rules_1_0_1.xml new file mode 100644 index 0000000..30ce3a7 --- /dev/null +++ b/app/.idea/libraries/com_android_support_test_rules_1_0_1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_android_support_test_runner_1_0_1.xml b/app/.idea/libraries/com_android_support_test_runner_1_0_1.xml new file mode 100644 index 0000000..b2bba34 --- /dev/null +++ b/app/.idea/libraries/com_android_support_test_runner_1_0_1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_google_code_findbugs_jsr305_2_0_1_jar.xml b/app/.idea/libraries/com_google_code_findbugs_jsr305_2_0_1_jar.xml new file mode 100644 index 0000000..6343119 --- /dev/null +++ b/app/.idea/libraries/com_google_code_findbugs_jsr305_2_0_1_jar.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/com_squareup_javawriter_2_1_1_jar.xml b/app/.idea/libraries/com_squareup_javawriter_2_1_1_jar.xml new file mode 100644 index 0000000..cdb8c22 --- /dev/null +++ b/app/.idea/libraries/com_squareup_javawriter_2_1_1_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/javax_inject_javax_inject_1_jar.xml b/app/.idea/libraries/javax_inject_javax_inject_1_jar.xml new file mode 100644 index 0000000..b028368 --- /dev/null +++ b/app/.idea/libraries/javax_inject_javax_inject_1_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/junit_junit_4_12_jar.xml b/app/.idea/libraries/junit_junit_4_12_jar.xml new file mode 100644 index 0000000..a026090 --- /dev/null +++ b/app/.idea/libraries/junit_junit_4_12_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/net_sf_kxml_kxml2_2_3_0_jar.xml b/app/.idea/libraries/net_sf_kxml_kxml2_2_3_0_jar.xml new file mode 100644 index 0000000..ee85b61 --- /dev/null +++ b/app/.idea/libraries/net_sf_kxml_kxml2_2_3_0_jar.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/org_hamcrest_hamcrest_core_1_3_jar.xml b/app/.idea/libraries/org_hamcrest_hamcrest_core_1_3_jar.xml new file mode 100644 index 0000000..8bc8974 --- /dev/null +++ b/app/.idea/libraries/org_hamcrest_hamcrest_core_1_3_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/org_hamcrest_hamcrest_integration_1_3_jar.xml b/app/.idea/libraries/org_hamcrest_hamcrest_integration_1_3_jar.xml new file mode 100644 index 0000000..6fd1927 --- /dev/null +++ b/app/.idea/libraries/org_hamcrest_hamcrest_integration_1_3_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/org_hamcrest_hamcrest_library_1_3_jar.xml b/app/.idea/libraries/org_hamcrest_hamcrest_library_1_3_jar.xml new file mode 100644 index 0000000..5225e0e --- /dev/null +++ b/app/.idea/libraries/org_hamcrest_hamcrest_library_1_3_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/modules.xml b/app/.idea/modules.xml new file mode 100644 index 0000000..3e7b693 --- /dev/null +++ b/app/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/vcs.xml b/app/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/app/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 576c654..ffa61b8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,8 +3,8 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { - applicationId "com.strobertchs.cs.mathgame" - minSdkVersion 14 + applicationId "com.strobertchs.mathgame" + minSdkVersion 18 targetSdkVersion 26 versionCode 1 versionName "1.0" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index effa7d1..1d195bf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="com.strobertchs.mathgame"> - + - + \ No newline at end of file diff --git a/app/src/main/java/com/strobertchs/cs/mathgame/Game.java b/app/src/main/java/com/strobertchs/cs/mathgame/Game.java deleted file mode 100644 index 607f47d..0000000 --- a/app/src/main/java/com/strobertchs/cs/mathgame/Game.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.strobertchs.cs.mathgame; -/** - * Models a game - * Created by robuntu on 11/12/17. - */ - -public class Game { - private int currentScore; - private int currentLevel; - - /** - * Construct a Game object, default score at 0 and level at 1 - */ - public Game(){ - resetScore(); - } - - /** - * Reset the score at 0 and level at 1 - */ - public void resetScore() { - currentScore = 0; - currentLevel = 1; - } - - - /** - * Update the currentScore based on the currentLevel - */ - public void updateScore(){ - for(int i = 1; i <= currentLevel; i++){ - currentScore = currentScore + i; - } - } - - /** - * Increase the level by 1 - */ - public void incrementLevel(){ - currentLevel++; - } - - /** - * Getter method for currentScore - * @return value of currentScore - */ - public int getCurrentScore() { - return currentScore; - } - - - /** - * Getter method for currentLevel - * @return value of currentLevel - */ - public int getCurrentLevel() { - return currentLevel; - } -} diff --git a/app/src/main/java/com/strobertchs/cs/mathgame/GameActivity.java b/app/src/main/java/com/strobertchs/cs/mathgame/GameActivity.java deleted file mode 100644 index e1ce2a6..0000000 --- a/app/src/main/java/com/strobertchs/cs/mathgame/GameActivity.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.strobertchs.cs.mathgame; - -import android.support.v7.app.AppCompatActivity; -import android.app.Activity; -import android.os.Bundle; -import android.view.View; -import android.view.WindowManager; -import android.widget.Button; -import android.widget.TextView; -import android.widget.Toast; - -import java.util.Random; - - -public class GameActivity extends Activity implements View.OnClickListener{ - - Button buttonObjectChoice1; - Button buttonObjectChoice2; - Button buttonObjectChoice3; - TextView textObjectPartA; - TextView textObjectPartB; - TextView textObjectScore; - TextView textObjectLevel; - - Game mathGame = new Game(); - Question currQuestion; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - //The next line loads our UI design to the screen - setContentView(R.layout.activity_game); - - - /*Here we get a working object based on either the button - or TextView class and base as well as link our new objects - directly to the appropriate UI elements that we created previously*/ - textObjectPartA = (TextView)findViewById(R.id.textPartA); - textObjectPartB = (TextView)findViewById(R.id.textPartB); - textObjectScore = (TextView)findViewById(R.id.textScore); - textObjectLevel = (TextView)findViewById(R.id.textLevel); - buttonObjectChoice1 = (Button)findViewById(R.id.buttonChoice1); - buttonObjectChoice2 = (Button)findViewById(R.id.buttonChoice2); - buttonObjectChoice3 = (Button)findViewById(R.id.buttonChoice3); - - buttonObjectChoice1.setOnClickListener(this); - buttonObjectChoice2.setOnClickListener(this); - buttonObjectChoice3.setOnClickListener(this); - - setQuestion(); - - }//onCreate ends here - - @Override - public void onClick(View view) { - //declare a new int to be used in all the cases - int answerGiven=0; - switch (view.getId()) { - - case R.id.buttonChoice1: - //initialize a new int with the value contained in buttonObjectChoice1 - //Remember we put it there ourselves previously - answerGiven = Integer.parseInt("" + buttonObjectChoice1.getText()); - - break; - - case R.id.buttonChoice2: - //same as previous case but using the next button - answerGiven = Integer.parseInt("" + buttonObjectChoice2.getText()); - - break; - - case R.id.buttonChoice3: - //same as previous case but using the next button - answerGiven = Integer.parseInt("" + buttonObjectChoice3.getText()); - - break; - - } - - updateScoreAndLevel(answerGiven); - setQuestion(); - - } - - void setQuestion(){ - - currQuestion = new Question(mathGame.getCurrentLevel()); - - textObjectPartA.setText(""+currQuestion.getPartA()); - textObjectPartB.setText(""+currQuestion.getPartB()); - - //set the multi choice buttons - //A number between 0 and 2 - Random randInt = new Random(); - int buttonLayout = randInt.nextInt(3); - switch (buttonLayout){ - case 0: - - buttonObjectChoice1.setText(""+currQuestion.getCorrectAnswer()); - buttonObjectChoice2.setText(""+currQuestion.getWrongAnswer1()); - buttonObjectChoice3.setText(""+currQuestion.getWrongAnswer2()); - - break; - - case 1: - buttonObjectChoice2.setText(""+currQuestion.getCorrectAnswer()); - buttonObjectChoice3.setText(""+currQuestion.getWrongAnswer1()); - buttonObjectChoice1.setText(""+currQuestion.getWrongAnswer2()); - break; - - case 2: - buttonObjectChoice3.setText(""+currQuestion.getCorrectAnswer()); - buttonObjectChoice1.setText(""+currQuestion.getWrongAnswer1()); - buttonObjectChoice2.setText(""+currQuestion.getWrongAnswer2()); - break; - } - } - - - void updateScoreAndLevel(int answerGiven){ - - if (currQuestion.guessIsCorrect(answerGiven)){ - Toast.makeText(getApplicationContext(), "Well done!", Toast.LENGTH_LONG).show(); - mathGame.updateScore(); - mathGame.incrementLevel(); - }else{ - Toast.makeText(getApplicationContext(), "Sorry", Toast.LENGTH_LONG).show(); - mathGame.resetScore(); - } - - //Actually update the two TextViews - textObjectScore.setText("Score: " + mathGame.getCurrentScore()); - textObjectLevel.setText("Level: " + mathGame.getCurrentLevel()); - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/strobertchs/cs/mathgame/MainActivity.java b/app/src/main/java/com/strobertchs/cs/mathgame/MainActivity.java deleted file mode 100644 index 81091f3..0000000 --- a/app/src/main/java/com/strobertchs/cs/mathgame/MainActivity.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.strobertchs.cs.mathgame; - -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.view.WindowManager; -import android.widget.Button; - - -public class MainActivity extends AppCompatActivity implements View.OnClickListener{ - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.activity_main); - final Button buttonPlay = (Button)findViewById(R.id.buttonPlay); - buttonPlay.setOnClickListener(this); - } - - @Override - public void onClick(View view) { - Intent i; - i = new Intent(this, GameActivity.class); - startActivity(i); - } -} diff --git a/app/src/main/java/com/strobertchs/cs/mathgame/Question.java b/app/src/main/java/com/strobertchs/cs/mathgame/Question.java deleted file mode 100644 index efdb936..0000000 --- a/app/src/main/java/com/strobertchs/cs/mathgame/Question.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.strobertchs.cs.mathgame; -import java.util.Random; - -/** - * Models a question in a math game - * Created by robuntu on 11/12/17. - */ - - -public class Question { - - private int partA; // the first operand - private int partB; // second operand - private int correctAnswer; - private int wrongAnswer1; - private int wrongAnswer2; - - /** - * Construct a multiplication question - * @param gameLevel used to set the range of values for the question - */ - public Question(int gameLevel){ - - int numberRange = gameLevel * 3; - Random randInt = new Random(); - - partA = randInt.nextInt(numberRange); - partA++;//not zero - - partB = randInt.nextInt(numberRange); - partB++;//not zero - - correctAnswer = partA * partB; - wrongAnswer1 = correctAnswer-2; - wrongAnswer2 = correctAnswer+2; - } - - /** - * Getter method for partA - * @return value of partA - */ - public int getPartA() { - return partA; - } - - - /** - * Getter method for partB - * @return value of partB - */ - public int getPartB() { - return partB; - } - - /** - * Getter method for correctAnswer - * @return value of correctAnswer - */ - public int getCorrectAnswer() { - return correctAnswer; - } - - - /** - * Getter method for wrongAnswer1 - * @return value of wrongAnswer1 - */ - public int getWrongAnswer1() { - return wrongAnswer1; - } - - - /** - * Getter method for wrongAnswer2 - * @return value of wrongAnswer2 - */ - public int getWrongAnswer2() { - return wrongAnswer2; - } - - - /** - * Check if a given answer is correct - * @param answerGiven the guessed answer - * @return true if the answer is correct - */ - public boolean guessIsCorrect(int answerGiven){ - return answerGiven == correctAnswer; - } - - - -} diff --git a/app/src/main/res/layout/activity_game.xml b/app/src/main/res/layout/activity_game.xml index 0fb241f..cb2d04a 100644 --- a/app/src/main/res/layout/activity_game.xml +++ b/app/src/main/res/layout/activity_game.xml @@ -4,99 +4,95 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="com.strobertchs.cs.mathgame.GameActivity"> - + tools:context="com.strobertchs.mathgame.GameActivity">