zoukankan      html  css  js  c++  java
  • 软工作业PSP与单元测试训练

    (一)任务说明

         实现模块判断传入的电子邮箱账号的正确性。

    (二)实现要求

        (1)实现功能模块:通过正则表达式进行简单的判断。

            (2)针对实现模块编写对应单元测试代码:

     1 /*
     2  * To change this license header, choose License Headers in Project Properties.
     3  * To change this template file, choose Tools | Templates
     4  * and open the template in the editor.
     5  */
     6 package emailcheck;
     7 
     8 import java.util.Scanner;
     9 import java.util.regex.Pattern;
    10 
    11 /**
    12  *
    13  * @author EvanPatrick
    14  */
    15 public class EmailCheck {
    16     public  static void main(String arg[]) {
    17         Scanner str=new Scanner(System.in);
    18         String email = str.nextLine(); 
    19            while(true)
    20           {
    21           
    22            if (EmailCheck.checkEmail(email))
    23            {   
    24                 System.out.println(email+"is legal Email address!");
    25                 break;
    26            }
    27            else
    28            {
    29                 System.out.println(email+"is illegal Email address!");
    30                 break;
    31            }
    32           }
    33        } 
    34      public static boolean checkEmail(String email) {     
    35             String pattern= "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";  
    36             return Pattern.matches(pattern, email);     
    37         }       
    38 }

    测试结果:

            (3)按PSP流程进行工作量估算,填写任务清单工作量估算表。

  • 相关阅读:
    程序员学习新技术的10个建议
    ES6 let和const总结归纳
    ES6 对象扩展运算符 res运算符
    ES6 变量的解构赋值
    ES6的开发环境搭建
    vue给同一元素绑定单击click和双击事件dblclick,执行不同逻辑
    "双非"应届生校招如何获得大厂青睐?(内附前端大厂面经+技术岗超全求职攻略)
    移动端300ms与点透总结
    Web移动端适配总结
    正则表达式总结
  • 原文地址:https://www.cnblogs.com/evanpatrick/p/8594003.html
Copyright © 2011-2022 走看看