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 Using a Model in the Controller

I'm completely stuck on the challenge after the "Formatting Strings" video in "Build an Interactive Story App".

I don't understand what is required of me for the first component of this question and have spent 2 hours as well as finishing the remainder of the course and am still unable to figure out what is required.

I had a lot of problems with this Code Challenge as well. I had to break down what the challenge wanted for each of the 3 exercises.

For this one I made a comment for each of the steps it wanted me to accomplish. // Set mSpaceship = new Spaceship Object // Pass the "FIREFLY" to the custom constructor

My answer looked like this: mSpaceship = new Spaceship("FIREFLY");

I hope this helps. I would definitely welcome a more indepth discussion on the how's, why's and what's of the answer as I'm not 100% sure I understand why this works.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Sorry for the confusion! Are the instructions for step 1 unclear? I can take a stab at trying to make it easier to understand.

2 Answers

Baruch Yochai
Baruch Yochai
4,624 Points

Solution for all 3 challenges is:

//setup new spaceship object  
        mSpaceship = new Spaceship("FIREFLY");

//set the text for the mTypeLabel TextView by using Spaceship's type  
      mTypeLabel.setText(mSpaceship.getType());

//store the number of passengers in the ship...
      mPassengersField.setText("" + mSpaceship.getNumPassengers());
shaun cook
shaun cook
2,662 Points

I am so glad this answer was here, i was close a few times but man...overall i feel my lack of being able to achieve this shows i didn't understand this as well as i should!

Many of the key concepts were just rushed over or referenced too. And these important concepts were hard to swallow. I may need to watch this whole series again just to try type it again and again....maybe it will sink in!

PS: Few things....

Not once did you use "m" for your objects/methods, even the answer above uses it, and the code challenge does not! So i had to edit this to match your "spaceship" which by the way also doesn't follow the camel case guidelines. basically spent ages during this entire project reviewing code to later find its because i was trying to use "proper" practice in one section and had "parrot copied" your code in a different section...

Working Answers:

//setup new spaceship object spaceship = new Spaceship("FIREFLY");

//set the text for the mTypeLabel TextView by using Spaceship's type
typeLabel.setText(spaceship.getShipType());

//store the number of passengers in the ship... passengersField.setText("" + spaceship.getNumPassengers());