软件测试作业三角形判定.docx

上传人:scccc 文档编号:13430831 上传时间:2021-12-25 格式:DOCX 页数:9 大小:125.58KB
返回 下载 相关 举报
软件测试作业三角形判定.docx_第1页
第1页 / 共9页
软件测试作业三角形判定.docx_第2页
第2页 / 共9页
软件测试作业三角形判定.docx_第3页
第3页 / 共9页
软件测试作业三角形判定.docx_第4页
第4页 / 共9页
软件测试作业三角形判定.docx_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《软件测试作业三角形判定.docx》由会员分享,可在线阅读,更多相关《软件测试作业三角形判定.docx(9页珍藏版)》请在三一文库上搜索。

1、课程名称:软件测试实验项目:判断三角形专业班级:软件0505班姓 名:学号:指导教师:昙澎沈阳工业大学实验报告(适用计算机程序设计类)专业班级:软件学院学号: 姓名: 实验名称:1 .实验目的:通过设计一个简单的判断程序,锻炼我们写程序的能力以及后期对输入输出数据的了解。2 .实验内容:从界面输入三条边的长度,判断这三条边是否构成三角形,若是,是什么样的三角形,输 出结果。3 .实验方案(程序设计说明)程序功能流程图:4 .实验步骤或程序(经调试后正确的源程序)见附件A5 .程序运行结果见附件A6 .出现的问题及解决方法附件A沈阳工业大学实验报告(适用计算机程序设计类)专业班级:软彳0505

2、学号: 姓名: 实验步骤或程序:1.设计窗口/*击窗口吉/public void MyFram已3 (Frame ± - new FtaniL”判断三角形"】二f.setBounds(100,100,200,400);f.setLayout(new FlowLayout(0,1030);f*addWindouListener(new WindowAdapter) put)in void windowclosing (UindowEvent e) System, exl t (0);):text 1 - new TextField(10);texts - ncTr TextF

3、ield( 10);text3 - ner TextField( 10);Label latoe 11 " new Label (r,Line_one :;Label latoe 12 - new Label (r,Line two :,r);Label latoe 13 - new Label (r,Line three:;f . add(latoe11);f. add (text 1):f. add (latoel2 );f.add(texti);f. add (latoe13 );f * add(text3);But ton b - new Button f ”开始第断力 $b

4、 * addict ionL istener(this);f. add(b)textii - nev TextF ield (20);f * add(text4);f . setVisitole (true);2.设计结构ModelMain是程序的主入口, 主要实现窗口的建立,从键盘接收三个变量,调用Triangle类的构造方法和判断方法,并打印出结果。Judge是一个判断接口定义了 3个方法Triangle是三角形类,实现了 Judge接口整吉第J' Judg janj m ModilH&in. java j Tri«n0&. j wpackage com.

5、ColiegeOfSoftware.sut;博F + ijnort j ava. awt, *;| puliXic c±ass ModelMain Tmlement? ActionL istenerprivate Triangle tr ;private static ModelMain irsa ;private TextField textl,reKt2rteyt3;private TextField text4; /*K程序入口* fpublic static void main(String ar95) f口 八* 窗口Enuhlic void HyFrame f) 1监听类

6、可public void ac 11 0 nP e r f or trie d (Ac t io nE vent e) / * 判断* /private void Judge() 1口/ * 打印I* /private void prmtText (String fJi HodelMain. j avapackage cothhCollegeOfSoitwiaE'e>aut:public class Triangle implements Judge private double line_one 工 private double line=two ; private doubl

7、e 1inethree ;日 / *构造函数*/* Triangle (douli±e llne_one , douhXe llne_cwa t double llne_c.hree) J -/*以下三个是Cvunidu的判断方法4 +ilb±icbooleanjudgeEquilateral (Triangle t) 卜 +pul)±icbooleanjudgelsosce les (Trianglec)|_d+liublicboolean(Triangle t)f匚/* 卡以下三个是得到宜迈叩1已类中私有变量的值. +public doub2_e gecLln

8、e_one () 1+iriiblic double g&CLine_two () (' |+ public dauble getLine_three() private void printText(String str) £3 .设计接口Java - VodelTrianel/ffrc/coB/CollegeOfSoTtvare/sut/Judge.j ava - EclipFile Edi t Source Refactor Mavigate Search Project Run 出indo皆 Help势,。,通湾第&-f .率日:I-团j wa 3:

9、jJ ModelMaiB. javaJ Tr i aikgl e. j avacam.CollegeOfSoftware .sut;public interface Judge (boolean judgeEquilateral Triangle tJ; boolean JudgeIsosceles (Triangle t);1)oolean judgeNorinl (Tr iarugle t);4 .实现内部功能T / *程序入口+ public static void inain (String args) ttitn = new ModelHain ();inmMyFrame ();Pr

10、ess ' F2' for focus/*F窗口*/public void MyFrame()(Frame ± = new Fuamu判断三角形:f . setBounds (1口0 . 100f 2:00, 400);f.setLayout(new FlowLayout(Q,10,30);£ T addWindciwLisCeiijer' (new Uindom Adapt er () puhlic void vindowC1osi(WindowEveat e) System,exj t(O);)*;textl = new TextField(10

11、);text2 = new Textfield(10);text3 = new TextFieId(10);Label labell = new Label (,rL ine_one :Tf);L»foel labe 12 - new Label (*L ine two:tf)Label labels = new Latoe 1 (,FLine_three:,r): f,add(latoell);f add (text 1);f ,add(.label2);f. add (text.2);£,add(labe13);f . add(texts);Button 匕=new B

12、utton("开始判断;b.addActionListener(this);f. add (h):= new TextField(20);f add(cext4);fsetVisible(true);才监听类pul)±ic void actionPerfcrmed(ActlonEvent e) try(tr = new Triangle ( Doukile. pars&Double (rextl, get Text (),Double.parseDcuble(rext2 .getText()fDouJole. pauseDouble (texts getText (

13、);rnhn. j iidge (); catch tNuniber Format Exo ept ion nf e) ( nfe.pu inbStackTrace();Press ' F±* fct focus*判断private void judge()i±(tr.judgeEqullateral(tr) Kim. print Text 等边三角彩"J ; else if (tr »judge Isosceles(tr) mm. print Text (,,等腰三角形"); else If (tr »judgeNortma

14、l (tr) mm.p匚intTEKtl"一般三角形叮; else <mm.print.Text ("不是二角形");打印private void printText(String str) text4.setText(str、;Press 72 for focus/*以下三个是Oveu ide的判断方法*/Overridepublic boolean judgeEqullateral(Triangle t) if( t.getLine one() =" t- getLine two () ££ t i getL ine_tii

15、ffo () = Z * getL ine_thrEe () ) return true;) return false;Over r iLle|Eiublic boolean judgersosceles (Triangle t) if ( t. getL ine one () = t + getLine_two i,) | | t,getLinetno(J = t,getLine_three() | t. getLine_one () = t * getLinet.hrEe () ) ( return true;) return false;Overr ideEiiLblic boolean

16、 judgeNorinal (Triangle t) if (t. get L ine_one (J 十七.getL 上口已_七血口 (>t. get Line_three () & st. getLine_t wo ( +t - getL Inehree () >t - getL ineone ("芯 t. getLine_thrse ) +t. getLine one () >t. getLine_tiiro () ( return true;puhlic? c±ass Trtangle implements Judge private doulile 1 inE_one ;private double 1ine_twc ;private doulxle 1 ine threS ; /*构造函数Triangle (double Line one / double line_two , double 1 ine_ttiree) this, line_cne = 13,ne_cne ; this, lirie_tuo = lme_tvo ; this., line three = line three :Press 'F21' for focus5.输出结果

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1