Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I have encountered an issue where everything works fine until the if ( result . equals ( Hello , + name

Hello I have encountered an issue where everything works fine until the
"if (result.equals("Hello,"+ name + "ready to start to the game?")){
nameField.setEnabled(false);
oneButton.setEnabled(true);
twoButton.setEnabled(true);
threeButton.setEnabled(true);
fourButton.setEnabled(true);
}"
this is the entire code:
private void nameButtonActionPerformed(java.awt.event.ActionEvent evt){
String name = nameField.getText();
String result = processUser(name);
storyArea.setText(result);
if (result.equals("Hello,"+ name + "ready to start to the game?")){
nameField.setEnabled(false);
oneButton.setEnabled(true);
twoButton.setEnabled(true);
threeButton.setEnabled(true);
fourButton.setEnabled(true);
}
}
public String processUser(String name){
if (name.length()>=12){
return("There are too many characters");
} else if (name.isEmpty()){
return("To begin the story, enter your name");
}else if (name.matches(".*[0-9!@#$%^&*()_+\\-=\\[\\]{};':\",.<>/?].*")){
return("No numbers or symbols allowed in the name");
}
return ("Hello,"+ name +" ready to start to the game?");
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

2. (1 point) Given AABC, tan A b b

Answered: 1 week ago