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 trialMUZ140584 Heredity Mbundire
4,979 Pointsam stuck on this challenge may you pliz help
Welcome to a little Twitter-like application. Here I'm modeling a Tweet. It has text which is the body of the tweet. All Tweets have a maximum character limit of 140 characters.
Please add a new constant to store the maximum number of characters allowed which is 140. Use the proper access level modifiers to make it unchangeable and accessible right off of the class. Follow the proper naming convention.
public int getTileCount(char letter);
int tileCount = 0;
for(char tile : mHand.toCharArray());
if(mHand.indexOf(tile) >= 0);
tileCount++;
}
return tileCount;
}}
5 Answers
Jess Sanders
12,086 PointsTry to connect the challenge tasks with the lesson tasks. It's a good strategy throughout the course.
public static final int MAX_MISSES = 7;
public int getRemainingTries() {
return MAX_MISSES - mMisses.length();
}
- Instead of MAX_MISSES, you are making MAX_CHARS
- Instead of getRemainingTries, you are making getRemainingChars
nobodyinhere
3,418 PointsYou need to add a constant field named "int static final MAX_VALUE = 140;" and you have to add this in your if else codes to confirm if it is lower than 140 chars or not.
simon bao
5,522 Pointspublic class Tweet {
private String mText;
public static final int MAX_LENGTH = 140;
public Tweet(String text) {
while(text.length() < MAX_LENGTH){
mText = text;
}
}
public String getText() {
return mText;
}
}
This is what I did and it worked, my code is rather simple.
chase singhofen
3,811 Pointsthis worked for me:
public class Tweet { private String mText; public static final int MAX_CHARS = 140; //chg to CHARS
i did like jess said and replaced LENGTH with CHARS everywhere in program. the video is similar. at first i didnt know where to put my constant, but i did know i needed a public static final b/c we dont want to chg anything
public Tweet(String text) { while(text.length() < MAX_CHARS){ //chg to CHARS mText = text; } }
public String getText() { return mText; } }//end of program
Prince Chinyadza
6,333 Pointspublic class Tweet { private String mtext; public static final int MAX_CHARS = 140;
public Tweet(String text) { while(text.length() < MAX_LENGTH){ mText = text; } } public String getText() { return mtext; }
public void setText(String text) { this.text = text; } }