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) The Model-View-Controller Pattern Adding Custom Constructors

Why did we use isBoolean??

I'm unable to understand why did he use boolean isBoolean in the video tutorial for Page Class Constructor??

Hugo Leon
Hugo Leon
7,763 Points

Hello Anirudh!

I'm on my way to learn more Java for Android so I'm not sure if my answer might help. But here it is.

I think in the video says that you have 7 pages in your app (0 to 6), and the number 5 and 6 have no choices to make anymore as the Story Map says. At your first Page Class constructor you have 4 parameters imageId, text, choice1 and choice2. Since you need pages without choices for the last 5 and 6) you need a custom Page constructor with only 2 parameters: imageId and text.

Into this custom constructor you need to initialize mChoice1 and mChoice2 to null because you will have no choices anymore, and a new boolean variable (mIsFinal) set to true.

Hope I've answered your question :)

Good luck with your courses!.

Thank you for answering my question so,patiently!! I understood everything except the declaration of boolean value "mISFinal".

Kane Stoboi
Kane Stoboi
21,919 Points

The declaration of a boolean object is much the same as any other other object.

Here is the code from the video

private boolean mIsFinal = false;

private: sets the member variable to be only accessible inside the class

boolean: declares that the object that is being created is a boolean object

mIsFinal: sets the variable name

false: Like any data type, boolean objects can contain a value. For a String object the value can be all types of characters enclosed in quote marks. Boolean data types can only have two possible values (true or false). In this case the Boolean is given a default value of false for every card. If the constructor is only given an 'imageId' or a 'text' value the page created must be one of the final cards therefore the value of mIsFinal changed to true meaning that it is a final card with no more choices available