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
Unsubscribed User
1,118 PointsNew method that returns the remaining characters available, based on the length stored in Text.
Hello, It says i need to try again. I cannot find my failing point. Please help me locate what i am doing wrong here
Here's the code:
public class Tweet {
private String mText;
public static final int MAX_CHARS = 140;
private int remChar;
public Tweet(String text) {
mText = text;
}
public String getText() {
return mText;
}
public int remCharAvailable (){
remChar = MAX_CHARS - mText.length();
return remChar;
}
}
1 Answer
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points- Task is not asking you to create new field
remChar. remove it - add
inttoremcharinremCharAvailablesince you don't have such member now:
public class Tweet {
private String mText;
public static final int MAX_CHARS = 140;
// private int remChar; // has to be removed
public Tweet(String text) {
mText = text;
}
public String getText() {
return mText;
}
public int remCharAvailable (){
int remChar = MAX_CHARS - mText.length(); // added int
return remChar;
}
}
Your logic and solution is great. But try to read very carefully the task. Because Task checker tests exactly what was asked for. And task checker is computer program :) That will help in challenges to come.