I am currently working on Cumulative Project No. 4. I am on step four:
Bring on the questions.
For your first setup task, create 3 or more Question
objects within startNewGame()
; refer to the SampleQuestions.txt
file for ideas or write your own!
Remember, all the values passed into the Question
constructor must be valid: an imageIdentifier
, a question statement for questionString
, four String
answers, and an integer representing the correct answer (0 through 3). Have fun and let loose while creating your questions!
The problem is I am not sure about what it means(or I’ve forgotten) to create 3 objects inside startNewGame()
Here is my code:
import java.util.ArrayList;
public class MainActivity {
// TODO #1: add integer member variables here
int currentQuestionIndex;
int totalCorrect;
int totalQuestoins;
// TODO #2: add ArrayList member variable here
ArrayList<String> questions = new ArrayList<String>();
// TODO #3 add startNewGame() here
public startNewGame(){
}
// TODO #4 add chooseNewQuestion() here
// TODO #5 add getCurrentQuestion() here
// TODO #6 add onAnswerSubmission() here
int generateRandomNumber(int max) {
double randomNumber = Math.random();
double result = max * randomNumber;
return (int) result;
}
String getGameOverMessage(int totalCorrect, int totalQuestions) {
if (totalCorrect == totalQuestions) {
return "You got all " + totalQuestions + " right! You won!";
} else {
return "You got " + totalCorrect + " right out of " + totalQuestions + ". Better luck next time!";
}
}
}