Question: private void nameButtonActionPerformed ( java . awt.event.ActionEvent evt ) { String name = nameField.getText ( ) ; String result = processUser ( name ) ;

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!