Question

In: Computer Science

Android Programming Create an app called GuessWho. The point of the app will to have the...

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.

Solutions

Expert 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;
    }
}


Related Solutions

Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create...
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create the layout for your score keeping app. The app should have: Two team names (TextViews) Two scores (TextViews) Buttons to increase/ decrease the scores An amount to change the score by (RadioButtons) You must have at least two score options The scores can be changed by anything you want American football: 1, 2, 3, 6 Basketball: 1, 2, 3 Freestyle wrestling: 1, 2, 3,...
android studio Begin a new app and create a Java class for products with data: productName,...
android studio Begin a new app and create a Java class for products with data: productName, productCode and price and use a file of objects to store product data and read back and display on screen. Do this by creating a simple form using EditTexts, buttons or ActionBar items and display output using an Alert.
use android studio or MIT inventor Create a Presidents Quiz App for your project with the...
use android studio or MIT inventor Create a Presidents Quiz App for your project with the following requirements: You must have images Buttons Label Conditional Statement Homepage with instructions Sound (music, buzzer, etc.) - Ensure you are using the correct layout: Gravity(Android Studio), Horizontal or Vertical Arrangement (MIT). - 40POINTS Points System (indicating how many answers they got wrong/correct). 20POINT 1-2 questions per President (45+ questions)
Develop an Android app to document the lifecycle of an “activity” For each callback events (onCreate(),...
Develop an Android app to document the lifecycle of an “activity” For each callback events (onCreate(), onStart()... ), record what callback event was triggered in the log(use Log.d); the message that is written to log should be defined in “strings.xml” and getResources.getString() should be used to retrieve the message. Implement onSaveInstanceState and onRestoreInstanceState – to track the number of times onSaveInstanceState is being called, in onRestoreInstanceState, print the value to the log file. Tag for “Log” statement should also be...
Hi! I need it in android studio and in java Design a game app “BouncingBall ”...
Hi! I need it in android studio and in java Design a game app “BouncingBall ” in which the user’s goal is to prevent a bouncing ball from falling off the bottom of the screen. When the user presses the start button, a ball bounces off the top, left and right sides (the “walls”) of the screen. A horizontal bar on the bottom of the screen serves as a paddle to prevent the ball from hitting the bottom of the...
Hi! I need it in android studio and in java Design a game app “BouncingBall ”...
Hi! I need it in android studio and in java Design a game app “BouncingBall ” in which the user’s goal is to prevent a bouncing ball from falling off the bottom of the screen. When the user presses the start button, a ball bounces off the top, left and right sides (the “walls”) of the screen. A horizontal bar on the bottom of the screen serves as a paddle to prevent the ball from hitting the bottom of the...
in phyton programming: with numpy Create a function called biochild.  The function has as parameters...
in phyton programming: with numpy Create a function called biochild.  The function has as parameters the number m and the lists ??????h?? and ??????h??.  The lists ??????h?? and ??????h?? contain 0’s and 1’s.  For example: ??????h?? = [1,0,0,1,0,1] and ??????h?? = [1,1,1,0,0,1]  Both lists have the same length ?.  The 0's and 1's represent bits of information (remember that a bit is 0 or 1).  The function has to generate a new list (child)....
android studio -Starting with a basic activity, create a new Java class (use File->New->Java class) called...
android studio -Starting with a basic activity, create a new Java class (use File->New->Java class) called DataBaseManager as in Lecture 5 and create a database table in SQLite, called StudentInfo. The fields for the StudentInfo table include StudentID, FirstName, LastName, YearOfBirth and Gender. Include functions for adding a row to the table and for retrieving all rows, similar to that shown in lecture 5. No user interface is required for this question, t -Continuing from , follow the example in...
Linda sells an android app. Her firm’s production function is f (x1, x2) = x1 +...
Linda sells an android app. Her firm’s production function is f (x1, x2) = x1 + 2x2 where x1 is the amount of unskilled labor and x2 is the amount of skilled labor that she employs. Draw the isoquant at 20 units of output and another at 40 units of output. Does this production function exhibit increasing, decreasing, or constant return to scale? If Linda faces factor prices (w1, w2) = (1, 1), what is the cheapest way to produce...
Programming Language : JAVA Create an interface named Turner, with a single method called turn(). Then...
Programming Language : JAVA Create an interface named Turner, with a single method called turn(). Then create 4 classes: 1- Leaf: that implements turn(), which changes the color of the Leaf object and returns true. If for any reason it is unable to change color, it should return false (you can come up with a reason for failure). The new color can be determined at random. 2- Document: that implements turn(), which changes the page on the document to the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT