Android Programming Create an app called GuessWho The point

Android Programming


Create an app called GuessWho.

The point of the app will to have the user play a guessing game based on a displayed image.

The user will be greeted with a screen that has an image of a person, four buttons and a next button. The four buttons should each have a different name on it. One of the names will be the actual name of the person in the image.

Your guess who quiz should consist of at least 5 questions. Each question should have a unique image and a different correct answer.

The Model of the app should be a QuizQuestion. The QuizQuestion should have an image resource ID for the person being guessed, the strings for the four possible guesses and what the right answer is.

Your model should have appropriate constructor and get/set methods.

Your app should tell the user if they are correct if they press the button with the correct name, and your app should tell the user they are wrong if they tap the button of an incorrect name.

There should be a next button that takes the user to the next question of the quiz.

If the user completes the last question of the quiz, your app should Toast to the screen how many correct guesses they had and how many incorrect guesses they had.

If the user gets to the end of the quiz and presses next, they should go back to the first question after seeing the Toast.

For portrait orientation the image should appear first, then two guess buttons below the image, then two more guess buttons below the image, then the next button on the bottom of the screen.

For landscape orientation, the image should appear on the left side of the screen. To the right should be the 4 guess buttons. To the right of the buttons should be the next button.

(Feel free to use different layouts then these if you think they look better. The point is there should be a different landscape and portrait layout.)

The Controller Activity class should be a class called GuessWhoActivity. This should be the lone activity in your app responsible for handling user interaction and displaying questions and answers.

The view should be your .xml layout files.

The app should remember what question the user was on if they switch from landscape to portrait mode. (Example: If they were on the 3rd question in portrait mode and switch to landscape, they should still be on the 3rd question when they get to landscape mode).
Make sure to not be using hard coded strings. Use strings.xml.

Solution

AndroidManifest.xml

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"
          package=\"com.bignerdranch.android.guesswho\">

    <application
        android:allowBackup=\"true\"
        android:icon=\"@mipmap/ic_launcher\"
        android:label=\"@string/app_name\"
        android:supportsRtl=\"true\"
        android:theme=\"@style/AppTheme\">
        <activity android:name=\".GuessWhoActivity\">
            <intent-filter>
                <action android:name=\"android.intent.action.MAIN\"/>

                <category android:name=\"android.intent.category.LAUNCHER\"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

GuessWhoActivity.java


import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class GuessWhoActivity extends AppCompatActivity {

    Button button1, button2, button3, button4, nextButton;
    ImageView quizImage;
    int mCurrentIndex;
    QuizQuestion questionList[] = {
            new QuizQuestion(R.drawable.jimenonamonanona, R.string.Wrong11,R.string.Wrong12,R.string.Wrong13 , R.string.Correct1 ,R.string.Correct1),
            new QuizQuestion(R.drawable.badluckbrian, R.string.Wrong21,R.string.Wrong22,R.string.Wrong23 , R.string.Correct2 ,R.string.Correct2),
            new QuizQuestion(R.drawable.boromir, R.string.Wrong31,R.string.Wrong32,R.string.Wrong33 , R.string.Correct3 ,R.string.Correct3),
            new QuizQuestion(R.drawable.gabenewell, R.string.Wrong41,R.string.Wrong42,R.string.Wrong43 , R.string.Correct4 ,R.string.Correct4),
            new QuizQuestion(R.drawable.kevenhart, R.string.Wrong51,R.string.Wrong52,R.string.Wrong53 , R.string.Correct5 ,R.string.Correct5),
            new QuizQuestion(R.drawable.mrbean, R.string.Wrong61,R.string.Wrong62,R.string.Wrong63 , R.string.Correct6 ,R.string.Correct6)
    };

//Hello
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guess_who);
        quizImage = (ImageView) findViewById(R.id.imageView1);
        button1 = (Button) findViewById(R.id.btn1);
        button2 = (Button) findViewById(R.id.btn2);
        button3 = (Button) findViewById(R.id.btn3);
        button4 = (Button) findViewById(R.id.btn4);
        setResources();

        nextButton = (Button) findViewById(R.id.nextButton);
        nextButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0){
                updateQuestion();
            }
        });

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                quizImage.setImageResource(R.drawable.mrbean);
            }
        });

    }

    public void updateQuestion() {
        mCurrentIndex = (mCurrentIndex + 1) % questionList.length;
        setResources();
    }
    public void setResources() {
        quizImage.setImageResource(questionList[mCurrentIndex].getImageResId());
        button1.setText(questionList[mCurrentIndex].getButtResId1());
        button2.setText(questionList[mCurrentIndex].getButtResId2());
        button3.setText(questionList[mCurrentIndex].getButtResId3());
        button4.setText(questionList[mCurrentIndex].getButtResId4());
    }

}


QuizQuestion.java


public class QuizQuestion {
//Image res ID
    //Strings of four trial answer
    //Correct answer gussed

    private int mImageResId;
    private int mButtResId1, mButtResId2, mButtResId3, mButtResId4;
    private int mCorrectguessResId;

    QuizQuestion(int _imageRedId, int _guess1, int _guess2, int _guess3, int _guess4, int _correctguess) {
        mImageResId = _imageRedId;
        mCorrectguessResId = _correctguess;
        mButtResId1 = _guess1;
        mButtResId2 = _guess2;
        mButtResId3 = _guess3;
        mButtResId4 = _guess4;
    }

    public int getImageResId() {
        return mImageResId;
    }

    public void setImageResId(int imageResId) {
        mImageResId = imageResId;
    }

    public int getButtResId1() {
        return mButtResId1;
    }

    public void setButtResId1(int buttResId1) {
        mButtResId1 = buttResId1;
    }

    public int getButtResId2() {
        return mButtResId2;
    }

    public void setButtResId2(int buttResId2) {
        mButtResId2 = buttResId2;
    }

    public int getButtResId3() {
        return mButtResId3;
    }

    public void setButtResId3(int buttResId3) {
        mButtResId3 = buttResId3;
    }

    public int getButtResId4() {
        return mButtResId4;
    }

    public void setButtResId4(int buttResId4) {
        mButtResId4 = buttResId4;
    }

    public int getCorrectguessResId() {
        return mCorrectguessResId;
    }

    public void setCorrectguessResId(int correctguessResId) {
        mCorrectguessResId = correctguessResId;
    }
}

Android Programming Create an app called GuessWho. The point of the app will to have the user play a guessing game based on a displayed image. The user will be
Android Programming Create an app called GuessWho. The point of the app will to have the user play a guessing game based on a displayed image. The user will be
Android Programming Create an app called GuessWho. The point of the app will to have the user play a guessing game based on a displayed image. The user will be
Android Programming Create an app called GuessWho. The point of the app will to have the user play a guessing game based on a displayed image. The user will be

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site