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 trialMUZ140961 Justice Musarurwa
4,637 Pointsparse Error Message
Set the title for the alert as "Hooray!", and set the message to "You did it!". Don't worry about setting any button text. Were am i going wrong???
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.widget.EditText;
public class GuessNumberActivity extends Activity {
protected String mUserInput;
protected EditText mUsername;
protected EditText mPassword;
protected EditText mEmail;
protected EditText mNumberField;
public void makeGuess() {
mUserInput = mNumberField.getText().toString();
// Set mUserInput here!
// Check to see if the user's number is correct
boolean isCorrect = GuessEngine.testGuess(mUserInput);
if(isCorrect == true){
AlertDialog.Builder builder = new AlertDialog.Builder(GuessNumberActivity.this);
builder.setMessage("You did it!");
builder.setTitle("Hooray!");
}
}
1 Answer
MUZ140961 Justice Musarurwa
4,637 Pointshow do i make guess a function
Georgiy Slobodenyuk
1,685 PointsThe problem is not makeGuess. You are missing a final }
at the end.
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.widget.EditText;
public class GuessNumberActivity extends Activity {
protected String mUserInput;
protected EditText mUsername;
protected EditText mPassword;
protected EditText mEmail;
protected EditText mNumberField;
public void makeGuess() {
mUserInput = mNumberField.getText().toString();
// Set mUserInput here!
// Check to see if the user's number is correct
boolean isCorrect = GuessEngine.testGuess(mUserInput);
if(isCorrect == true){
AlertDialog.Builder builder = new AlertDialog.Builder(GuessNumberActivity.this);
builder.setMessage("You did it!");
builder.setTitle("Hooray!");
}
}
}
Georgiy Slobodenyuk
1,685 PointsGeorgiy Slobodenyuk
1,685 PointsSeems like you are missing a closing
}
at the end. You close out theif
and themakeGuess
function, but not thepublic class