資源描述:
《JAVAlab5-6--曾琪》由會(huì)員上傳分享,免費(fèi)在線(xiàn)閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、云南大學(xué)軟件學(xué)院實(shí)驗(yàn)報(bào)告課程:JAVA程序設(shè)計(jì)學(xué)期:2010-2011學(xué)年第一學(xué)期任課教師:陸歌浩專(zhuān)業(yè):軟件工程學(xué)號(hào):20081120292姓名:曾琪成績(jī):Lab#5ApplyingOOConceptsUsingJavaCreateaclasscalledCircle.javawithfieldsnamedradius,area,anddiameter.?IncludemethodsnamedsetRadius(),getRadius,andcomputeDiameter(),whichcalcul
2、atesthecircle'sdiameter,andcomputeArea(),whichcomputesthecircle'sarea.?Hint:?diameterofacircleistwiceitsradius.?Hint:?areaofacircleis3.14multipliedbythesquareoftheradius.?CreateaclasscalledTestCircle.javawhosemainmethoddeclares2Circleobjects.?UsingsetR
3、adius()method,assignoneCircleasmallradiusvalueandassignanotheralargerradiusvalue.?CallcomputeDiameter()andcomputeAreaforeachcircleanddisplaytheresults.一.實(shí)驗(yàn)代碼:publicclassTestCircle{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubCirclec
4、ircle=newCircle();Circlecircle2=newCircle();System.out.println("-------曾琪-----20081120292---------");System.out.println("====================================");circle.setRadius(5.0);circle2.setRadius(8.0);System.out.println("Theareaofais"+circle.comput
5、eArea());System.out.println("Thediameterofais"+circle.computeDiameter());System.out.println("Theareaofais"+circle2.computeArea());System.out.println("Thediameterofais"+circle2.computeDiameter());;}}publicclassTestCircle{publicstaticvoidmain(String[]arg
6、s){//TODOAuto-generatedmethodstubCirclecircle=newCircle();Circlecircle2=newCircle();System.out.println("-------曾琪-----20081120292---------");System.out.println("====================================");circle.setRadius(5.0);circle2.setRadius(8.0);System.
7、out.println("Theareaofais"+circle.computeArea());System.out.println("Thediameterofais"+circle.computeDiameter());System.out.println("Theareaofais"+circle2.computeArea());System.out.println("Thediameterofais"+circle2.computeDiameter());;}}二.實(shí)驗(yàn)結(jié)果云南大學(xué)軟件學(xué)院
8、實(shí)驗(yàn)報(bào)告課程:JAVA程序設(shè)計(jì)學(xué)期:2010-2011學(xué)年第一學(xué)期任課教師:陸歌浩專(zhuān)業(yè):軟件工程學(xué)號(hào):20081120292姓名:曾琪成績(jī):Lab#6一.實(shí)驗(yàn)代碼publicclassMakePerson{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubPersonperson1=newPerson("Mr.","Michael","Zheng","Mokey",30,true);Per