diff --git a/src/edu/auburn/csse/comp3710/AuburnTriviaGame.java b/src/edu/auburn/csse/comp3710/AuburnTriviaGame.java index a0e1a9e..6a1f5d1 100644 --- a/src/edu/auburn/csse/comp3710/AuburnTriviaGame.java +++ b/src/edu/auburn/csse/comp3710/AuburnTriviaGame.java @@ -65,15 +65,16 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { scores[4] = settings.getInt("high5", 0); scores[5] = new_score; + // Log.d("Game", "before" + Arrays.toString(scores)); Arrays.sort(scores); + // Log.d("Game", "before" + Arrays.toString(scores)); SharedPreferences.Editor update = settings.edit(); - - settings.getInt("high1", scores[5]); - settings.getInt("high2", scores[4]); - settings.getInt("high3", scores[3]); - settings.getInt("high4", scores[2]); - settings.getInt("high5", scores[1]); - + + update.putInt("high1", scores[5]); + update.putInt("high2", scores[4]); + update.putInt("high3", scores[3]); + update.putInt("high4", scores[2]); + update.putInt("high5", scores[1]); update.commit(); Context context = getApplicationContext(); diff --git a/src/edu/auburn/csse/comp3710/DataHelper.java b/src/edu/auburn/csse/comp3710/DataHelper.java index 916ce7e..4545f2e 100644 --- a/src/edu/auburn/csse/comp3710/DataHelper.java +++ b/src/edu/auburn/csse/comp3710/DataHelper.java @@ -11,7 +11,7 @@ public class DataHelper { private static final String DATABASE_NAME = "AuburnTrivia.db"; private static final int DATABASE_VERSION = 8; - public enum QuestionTypes {Any, General, Sports, Eng}; + public enum QuestionTypes { Any, General, Sports, Eng }; private Context context; private SQLiteDatabase db; @@ -25,8 +25,7 @@ public DataHelper(Context context) { } private void checkData() { - try - { + try { Cursor cursor = this.db.rawQuery("select * from Questions", null); cursor.moveToFirst(); cursor.isNull(0); @@ -47,14 +46,12 @@ public void clearUsed() { } } - public String[] selectQuestion(QuestionTypes type, int difficulty) - { + public String[] selectQuestion(QuestionTypes type, int difficulty) { Cursor question = null; //TODO: set used bit in DB for selected question - try - { + try { //TODO: deal with when select doesn't exist switch (type) { case Any: @@ -80,8 +77,7 @@ public String[] selectQuestion(QuestionTypes type, int difficulty) } } - catch(Exception ex) - { + catch(Exception ex) { Log.e("DBHelper", ex.getMessage()); } @@ -114,8 +110,7 @@ private void checkUsed(int difficulty, String type) { //TODO: have list of questions for current difficulty used in current gameplay so when all are cleared they are marked as used. - if(allUsed == 0) - { + if(allUsed == 0) { String currentQuery; if (type == "any") { currentQuery = "update questions set used = 0 where difficulty = " + difficulty; diff --git a/src/edu/auburn/csse/comp3710/Question.java b/src/edu/auburn/csse/comp3710/Question.java index dbe6fc3..ffedb8b 100644 --- a/src/edu/auburn/csse/comp3710/Question.java +++ b/src/edu/auburn/csse/comp3710/Question.java @@ -31,7 +31,6 @@ public String getCorrectAnswer() public String[] getWrongAnswers() { - return WrongAnswer; } @@ -63,8 +62,6 @@ public String executeCram() } else { - - while(iterator < 3) { if(WrongAnswer[iterator] != null) diff --git a/src/edu/auburn/csse/comp3710/Questions.java b/src/edu/auburn/csse/comp3710/Questions.java index b8f031e..1411cc9 100644 --- a/src/edu/auburn/csse/comp3710/Questions.java +++ b/src/edu/auburn/csse/comp3710/Questions.java @@ -25,7 +25,7 @@ public class Questions extends Activity { int QuestionCount = 1; Question currentQuestion = null; - /** Called when the activity is first created. */ + /* Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -68,14 +68,12 @@ public void onCreate(Bundle savedInstanceState) { Button HintButtom = (Button)findViewById(R.id.HintButton); HintButtom.setOnClickListener(new View.OnClickListener() { - @Override public void onClick(View v) { TextView hintText = (TextView)findViewById(R.id.hint); hintText.setVisibility(hintText.VISIBLE); Button hintButton = (Button)findViewById(R.id.HintButton); hintButton.setVisibility(hintButton.INVISIBLE); - } }); @@ -118,8 +116,6 @@ public void onClick(View v) { FiftyFiftyBtn.setVisibility(FiftyFiftyBtn.INVISIBLE); } }); - - } public void setCurrentQuestion(int difficulty) { @@ -128,10 +124,10 @@ public void setCurrentQuestion(int difficulty) { //TODO: Dynamically change order so first answer is not always the correct answer try { TextView question = (TextView)findViewById(R.id.Question); - question.setText(currentQuestion.getQuestion()); + question.setText(currentQuestion.getQuestion()); TextView hint = (TextView)findViewById(R.id.hint); - hint.setText("HINT: " + currentQuestion.getHint()); + hint.setText("HINT: " + currentQuestion.getHint()); hint.setVisibility(hint.INVISIBLE); //Always set all buttons as visible incase there has been a 50/50 call @@ -141,9 +137,7 @@ public void setCurrentQuestion(int difficulty) { list.add((Button)findViewById(R.id.Answer2)); list.add((Button)findViewById(R.id.Answer3)); list.add((Button)findViewById(R.id.Answer4)); - - - + Collections.shuffle(list); Button btn = list.remove(0); @@ -184,12 +178,9 @@ public void onClick(View v) { } }); } - catch(Exception EX) - { - Log.e("Questions", EX.getMessage()); - } - - + catch(Exception e) { + Log.e("Questions", e.getMessage()); + } } public void endQuestions() { @@ -209,11 +200,11 @@ public void updateQuestions() { public void nextQuestion() { - if(QuestionCount < 13) + if( QuestionCount < 13) { difficulty = QuestionCount/3; - if(QuestionCount%3 != 0) + if (QuestionCount % 3 != 0) { difficulty++; }