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 trialMichael McKenna
3,451 PointsWhat is the purpose of the choice class in Interactive Story?
The code below is as follows. I don't understand why we need it (because I'm not conceptualizing what is going on here). Any explanation will be greatly appreciated!
public class Choice { private String mText; private int mNextPage;
public Choice(String text, int nextPage) {
mText = text;
mNextPage = nextPage;
}
public String getText() {
return mText;
}
public void setText(String text) {
mText = text;
}
public int getNextPage() {
return mNextPage;
}
public void setNextPage(int nextPage) {
mNextPage = nextPage;
}
}
1 Answer
Michael McKenna
3,451 PointsYeah, this class has the getters and setters for the variables above. You can set the text here then get it from another point in your code with the getText() method. It's relatively simple, just don't over think it
Alex Johnson
6,067 PointsAlex Johnson
6,067 PointsI'm curious about this too so am digging into it right now. Did you ever figure out what exactly it does?