zoukankan      html  css  js  c++  java
  • 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相比,这个测试其实没什么区别,只是在数量上多了一些而已。

  • 相关阅读:
    python中的__init__
    python中的单例模式
    python中闭包和装饰器
    sql多表查询
    configurationChanges
    excludeFromRecents标签
    activity-alias
    meta-data
    launchMode
    Apache ant 配置
  • 原文地址:https://www.cnblogs.com/HCS1995/p/4376276.html
Copyright © 2011-2022 走看看