Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

What is the purpose of the Page class in the Interactive Story example app?

Similar to the Choice class, I am having troubles conceptualizing what is going on in the code and how it makes the app go to the next page after pressing the button, and how it knows which page it goes to. The code below is the Page.java class from the app. Any explanation will be greatly appreciated!

public class Page { private int mImageId; private String mText; private Choice mChoice1; private Choice mChoice2; private boolean mIsFinal = false;

public Page(int imageId, String text, Choice choice1, Choice choice2) {
    mImageId = imageId;
    mText = text;
    mChoice1 = choice1;
    mChoice2 = choice2;
}

public boolean isFinal() {
    return mIsFinal;
}

public void setFinal(boolean isFinal) {
    mIsFinal = isFinal;
}

public Page(int imageId, String text) {
    mImageId = imageId;
    mText = text;
    mChoice1 = null;
    mChoice2 = null;
    mIsFinal = true;

}

public int getImageId() {
    return mImageId;
}

public String getText() {
    return mText;
}

public void setText(String text) {
    mText = text;
}

public Choice getChoice1() {
    return mChoice1;
}

public void setChoice1(Choice choice1) {
    mChoice1 = choice1;
}

public Choice getChoice2() {
    return mChoice2;
}

public void setChoice2(Choice choice2) {
    mChoice2 = choice2;
}

public void setImageId(int id) {
    mImageId = id;
}

}