软件测试技术实验报告

上传人:博****1 文档编号:431443675 上传时间:2023-10-16 格式:DOCX 页数:43 大小:1.01MB
返回 下载 相关 举报
软件测试技术实验报告_第1页
第1页 / 共43页
软件测试技术实验报告_第2页
第2页 / 共43页
软件测试技术实验报告_第3页
第3页 / 共43页
软件测试技术实验报告_第4页
第4页 / 共43页
软件测试技术实验报告_第5页
第5页 / 共43页
点击查看更多>>
资源描述

《软件测试技术实验报告》由会员分享,可在线阅读,更多相关《软件测试技术实验报告(43页珍藏版)》请在金锄头文库上搜索。

1、软件测试技术实验报告河北工业大学计算机科学与软件学院2017年9月软件说明电话号码问题某城市电话号码由三部分组成。它们的名称和内容分别是:地区码:空白或三位数字;前 缀:非0或1的三位数字;后缀:4位数字。流程图空白|0-9内 三位数字?2-9内三位数 字?0-9内四位数 字?接受此电话号码拒箜此电话号码源代码import java.awt.*;import java.awt.event.*;public class PhoneNumber extends Frame implements ActionListener(/*/private static final long serialVe

2、rsionUID = 1L;private final String st = Name”,”Local”,”Prefix”,”Suffix”; static int c_person=0;TextField t_name,t_local,t_prefix,t_suffix;RecordDialog d_record;MessageDialog d_message;person a=new person100;public PhoneNumber()super(-电话号码”);this.setSize(250,250);this.setLocation(300,240);Panel panel

3、1 = new Panel(new GridLayout(4, 1);for (int i = 0; i st.length; i+)panel1.add(new Label(sti,0);Panel panel2 = new Panel(new GridLayout(4, 1);t_name =new TextField(”,20);t_local =new TextField();t_prefix=new TextField();t_suffix=new TextField();panel2.add(t_name);panel2.add(t_local);panel2.add(t_pref

4、ix);panel2.add(t_suffix);Panel panel3 = new Panel(new FlowLayout();Button b_save = new Button(Save);Button b_record= new Button(Record);panel3.add(b_save);panel3.add(b_record);this.setLayout(new BorderLayout();this.add(West”, panel1);this.add(East”, panel2);this.add(South”, panel3);addWindowListener

5、(new WindowCloser();b_save.addActionListener(this);b_record.addActionListener(this);d_record=new RecordDialog(this);d_message=new MessageDialog(this);this.setVisible(true);private class RecordDialog extends Dialog(private static final long serialVersionUID = 1L;Frame frame;对话框所依赖的框架窗口TextArea t_show

6、;RecordDialog(Frame frame)(super(frame,记录,true);this.frame=frame;this.setSize(300, 80);t_show=new TextArea(20,20);this.add(t_show);this.addWindowListener(new WindowCloser();public void show(String s) (t_show.setText(s);this.setLocation(frame.getX()+100, frame.getY()+100);this.setVisible(true);privat

7、e class MessageDialog extends Dialog/*/private static final long serialVersionUID = 1L;Frame frame;/对话框所依赖的框架窗口Label label;对话框中显示信息MessageDialog(Frame frame)super(frame,消息,true);this.frame=frame;this.setSize(300, 80);label=new Label(”,Label.CENTER);this.add(label);this.addWindowListener(new WindowCl

8、oser();public void show(String string)label.setText(string);this.setLocation(frame.getX()+100, frame.getY()+100);this.setVisible(true);private class WindowCloser extends WindowAdapter(public void windowClosing(WindowEvent we)(Window label = we.getWindow();label.setVisible(false);private class person

9、(String name,local,prefix,suffix;person(String name,String local,String prefix,String suffix)( this.name=name;this.local=local;this.prefix=prefix;this.suffix=suffix;public String getname()(return name;public String getlocal()( return local;public String getprefix()(return prefix;public String getsuf

10、fix()( return suffix;public String toString()(returnthis.getname()+t+this.getlocal()+t+this.getprefix()+t+this.getsuffix()+n”;public boolean check(String local,String prefix,String suffix)if(local.equals()|(local.length()=3&local.matches(0-9+)&(prefix.length()=3&prefix.matches(2-9+)&(suffix.length()

11、=4&suffix.matches(0-9+)return true;return false;public void actionPerformed(ActionEvent e) (String label = e.getActionCommand();if(label=Save)String name=t_name.getText();String local=t_local.getText();String suffix=t_suffix.getText();String prefix=t_prefix.getText();if(check(local,prefix,suffix)ac_

12、person=new person(name,local,prefix,suffix);c_person+;elseString message=;if(!local.equals()&(local.length()!=3|!local.matches(0-9+) message+=local is error,;if(prefix.length()!=3|!prefix.matches(2-9+) message+=prefix is error,;if(suffix.length()!=4|!suffix.matches(0-9+) message+=suffix is error;mes

13、sage+=please input again.;d_message.show(message);t_name.setText();t_local.setText();t_prefix.setText();t_suffix.setText();if(label=Record)d_record.show(this.toshow();public String toshow()String s=nametlocaltprefixtsuffixn;for(int i=0;ic_person;i+)s+=ai.toString();return s;public static void main(S

14、tring arg)new PhoneNumber();界面图电话号码口回1,NameLocalPrefixSuffiKSave | R2gd |匡习.一 XNameLocalPrefixSuffixit333二I消息local is error pl ease input again.Ml电.NameLocalPrefixsumx1144ill匡I消息xprefix is error.please input aaair.WEM d_record;理叩p;new per son10;Save | RecordmJ电NameLocalPreTiiSuffix国电.一 口 XNameC3msUS叵1记录XriairielocalJ123prefiz333345444suffix

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 机械/制造/汽车 > 综合/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号