Cumulative project 4 (Unquote) Step 16 and others

I’m unsure if it is asking me to uncomment the displayQuestionsRemaining line or write my own. I’m finding this project really difficult and the hints don’t really help me.

My current code is this (also is the code in TODO 4 correct?):

import java.util.ArrayList;

public class MainActivity {

    // TODO #1: add integer member variables here
  int currentQuestionIndex;
  int totalCorrect;
  int totalQuestions;
    // TODO #2: add ArrayList member variable here
  ArrayList<Question> questions = new ArrayList<Question>();
    // TODO #3 add startNewGame() here    
  public void startNewGame(){
    Question question1 = new Question(921238, "How tall is the Eiffel tower?","1024 ft","1063 ft","1124 ft","1163 ft",1);
    Question question2 = new Question(107343,"Who invented the computer algorithm?","Charles Babbage","John Carmack","Alan Turing","Ada Lovelace",3);
    Question question3 = new Question(748294,"What is the name for the patch of skin found on your elbow?","Elbow Skin","Fascia Elbora","Wenis","Todd",2);
    totalCorrect = 0;
    totalQuestions = questions.size();
    Question firstQuestion = chooseNewQuestion();
    // displayQuestion(firstQuestion);
    // displayQuestionsRemaining(questions.size());
    // TODO #4 add chooseNewQuestion() here
  public Question chooseNewQuestion(){
    int local = generateRandomNumber(2);
    currentQuestionIndex = local;
    return questions.get(currentQuestionIndex); 
    // TODO #5 add getCurrentQuestion() here
  public Question getCurrentQuestion(){
    return questions.get(currentQuestionIndex);
    // TODO #6 add onAnswerSubmission() here
  public void onAnswerSubmission(){
      Question currentQues = getCurrentQuestion();
      if (currentQues.isCorrect()) {
        totalCorrect += 1;

    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!";

Hello @cloud2771800363, welcome to the forums! Unfortunately, I don’t have PRO; could use post a screenshot of the relevant instructions, please?

1 Like

Here is a screenshot of the instructions:

the weird thing is //displayQuestionsRemaining(questions.size()); isn’t in or below the code in the previous task, so I have no idea why it mentions it. Do they want me to uncomment it? So vague and confusing.

I’m really sorry for the late reply, could you post a screenshot of the LE? (That is if you haven’t gotten past this…)

Hi sorry I gave up, I’m doing the Android courses on udacity now, it’s much better

1 Like

Oh, ok!