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 Build an Interactive Story App (Retired) Finishing the User Interface Loading the First Page

.getPage in the dot syntax cannot resolve symbol. What did I miss in the videos?

When creating the vairiable Page page = new mStory.getPage(0); in the loadPage method, the .getPage is in the predictive dot syntax, but it can not resolve the symbol. Did i miss setting a member variable in the Page.class?

here is my Page.class

<>
package com.example.thejacquet3.interactivestory.model;

/**
 * Created by thejacquet3 on 5/31/16.
 */
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 Page(int imageId, String text){
        mImageID = imageId;
        mText = text;
        mChoice1 = null;
        mChoice2 = null;
    }

    public boolean isFinal() {
        return mIsFinal;

    }

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

    public int getImageID() {
        return mImageID;
    }

    public void setImageID(int imageID) {
        mImageID = imageID;
    }

    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;
</p>

1 Answer

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

That code is correct. What about your return statement...does it look like this?

return mPages[pageNumber]

yes here is a snippet from the Story class

        mPages[6] = new Page(
                R.mipmap.page6,
                "You arrive home on Earth. While your mission was a success, " +
                        "you forever wonder what was sending that signal. " +
                        "Perhaps a future mission will be able to investigate...");
    }

    public Page getPage(int pageNumber) {
        return mPages[pageNumber];
    }
}