UserForm扩展问题

关于userform的扩展,这次是在三个输入框里输入密码,密码的格式都为:

  允许1到6个英文字符或数字,按OK结束
 
等价类划分:
 

等价类表:

测试代码:

Button btn = new Button("OK");
AnchorPane.setTopAnchor(btn, 140.0);
AnchorPane.setLeftAnchor(btn, 130.0);
root.getChildren().add(btn);

btn.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent actEvt) {
if((check(t2.getText().toString())))
System.out.println("true");
else
System.out.println("false");
if((check(t4.getText().toString())))
System.out.println("true");
else
System.out.println("false");
if((check(t6.getText().toString())))
System.out.println("true");
else
System.out.println("false");
}
});

public boolean check(String s){
char array[] = new char[s.length()];
array = s.toCharArray();
if (s.length() < 1 || s.length() > 6)
return false;
if (s.length() != 0){
for (int i = 0; i < s.length(); i++){
if(!Character.isDigit(array[i]) && !Character.isAlphabetic(array[i]))
return false;
}
}
return true;
}

测试用例:

测试结果:

与之前那个UserForm相比,这个测试其实没什么区别,只是在数量上多了一些而已。

原文地址:https://www.cnblogs.com/HCS1995/p/4376276.html