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 trialWill Sokolowski
2,292 PointsCan't Pass the constructor part of this training
I'm currently at Adding a custom constructor in the Build an interactive story course. Everything is working fine, but my code isn't working. Here's the code.
package com.inmotionhosting.gostories.model;
/**
- Created by Will S on 4/27/2017. */
import com.inmotionhosting.gostories.R;
public class Story {
private Page[] pages;
public Story() {
pages = new Page[7];
pages[0] = new Page(R.drawable.page0,
R.string.page0,
new Choice(R.string.page0_choice1, 1),
new Choice(R.string.page0_choice2, 2));
pages[1] = new Page(R.drawable.page1,
R.string.page1,
new Choice(R.string.page1_choice1, 3),
new Choice(R.string.page1_choice2, 4));
pages[2] = new Page(R.drawable.page2,
R.string.page2,
new Choice(R.string.page2_choice1, 4),
new Choice(R.string.page2_choice2, 6));
pages[3] = new Page(R.drawable.page3,
R.string.page3,
new Choice(R.string.page3_choice1, 4),
new Choice(R.string.page3_choice2, 5));
pages[4] = new Page(R.drawable.page4,
R.string.page4,
new Choice(R.string.page4_choice1, 5),
new Choice(R.string.page4_choice2, 6));
pages[5] = new Page(R.drawable.page5, R.string.page5);
pages[6] = new Page(R.drawable.page6, R.string.page6);
}
}
It says cannot resolve symbol 'page6' and i can't figure out why. This is the code directly from the github repo. I've looked at all my other code, and there aren't any errors. Am I missing something here?
3 Answers
Seth Kroger
56,413 PointsWhich page6? The drawable or the string? Android Studio should be telling you which. Check both that there's a page6 in drawable and that there is a string for page6 in strings.xml. No typos.
mohamadreza azadi
5,167 Pointsi think your version of android studio is diffrent you need to do try this code on your code R.mipmap.page0; mipmap is where is the place store your images
Will Sokolowski
2,292 PointsOh jeez....just some attention to detail....spend so much time looking at all the other code...and simply didn't have this in strings.xml
<string name="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…</string>
Thanks for the help!