軟件測試作業(yè)三角形判定_第1頁
軟件測試作業(yè)三角形判定_第2頁
軟件測試作業(yè)三角形判定_第3頁
軟件測試作業(yè)三角形判定_第4頁
軟件測試作業(yè)三角形判定_第5頁
已閱讀5頁,還剩4頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、課程名稱:軟件測試實驗項目:判斷三角形專業(yè)班級:軟件0505班姓 名:學(xué)號:指導(dǎo)教師:曇澎沈陽工業(yè)大學(xué)實驗報告(適用計算機(jī)程序設(shè)計類)專業(yè)班級:軟件學(xué)院學(xué)號: 姓名: 實驗名稱:1 .實驗?zāi)康模和ㄟ^設(shè)計一個簡單的判斷程序,鍛煉我們寫程序的能力以及后期對輸入輸出數(shù)據(jù)的了解。2 .實驗內(nèi)容:從界面輸入三條邊的長度,判斷這三條邊是否構(gòu)成三角形,若是,是什么樣的三角形,輸 出結(jié)果。3 .實驗方案(程序設(shè)計說明)程序功能流程圖:4 .實驗步驟或程序(經(jīng)調(diào)試后正確的源程序)見附件A5 .程序運行結(jié)果見附件A6 .出現(xiàn)的問題及解決方法附件A沈陽工業(yè)大學(xué)實驗報告(適用計算機(jī)程序設(shè)計類)專業(yè)班級:軟彳0505

2、學(xué)號: 姓名: 實驗步驟或程序:1.設(shè)計窗口/*擊窗口吉/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.設(shè)計結(jié)構(gòu)ModelMain是程序的主入口, 主要實現(xiàn)窗口的建立,從鍵盤接收三個變量,調(diào)用Triangle類的構(gòu)造方法和判斷方法,并打印出結(jié)果。Judge是一個判斷接口定義了 3個方法Triangle是三角形類,實現(xiàn)了 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監(jiān)聽類

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 ;日 / *構(gòu)造函數(shù)*/* 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 .設(shè)計接口Java - VodelTrianel/ffrc/coB/CollegeOfSoTtvare/sut/Judge.j ava - EclipFile Edi t Source Refactor Mavigate Search Project Run 出indo皆 Help勢,。,通灣第&-f .率日:I-團(tuán)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 .實現(xiàn)內(nèi)部功能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);才監(jiān)聽類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

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論