java2实用教程第四版实验 清华大学出版社5-1 5-2(北华大学吕磊)

java2实用教程第四版实验 清华大学出版社5-1 5-2(北华大学吕磊)

ID:14383800

大小:44.00 KB

页数:8页

时间:2018-07-28

java2实用教程第四版实验 清华大学出版社5-1 5-2(北华大学吕磊)_第1页
java2实用教程第四版实验 清华大学出版社5-1 5-2(北华大学吕磊)_第2页
java2实用教程第四版实验 清华大学出版社5-1 5-2(北华大学吕磊)_第3页
java2实用教程第四版实验 清华大学出版社5-1 5-2(北华大学吕磊)_第4页
java2实用教程第四版实验 清华大学出版社5-1 5-2(北华大学吕磊)_第5页
资源描述:

《java2实用教程第四版实验 清华大学出版社5-1 5-2(北华大学吕磊)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、实验5-1classPeople{protecteddoubleweight,height;publicvoidspeakHello(){System.out.println("yayayaya");}publicvoidaverageHeight(){height=173;System.out.println("averageheight:"+height);}voidaverageWeigh(){weight=70;System.out.println("averageweight:"+weight);}}classC

2、hinaPeopleextendsPeople{publicvoidspeakHello(){System.out.println("您好");}publicvoidaverageHeight(){height=168.78;System.out.println("中国人的平均身高:"+height+"厘米");}publicvoidaverageWeight(){weight=65;System.out.println("中国人的平均体重:"+weight+"千克");}publicvoidchinaGongfu(){S

3、ystem.out.println("坐如钟,站如松,睡如弓");}}classAmericanPeopleextendsPeople{publicvoidspeakHello(){System.out.println("Howdoyoudo");}publicvoidaverageHeight(){height=176;System.out.println("American'saverageheight:"+height+"cm");}publicvoidaverageWeight(){weight=75;System

4、.out.println("American'saverageweight:"+weight+"kg");}publicvoidamericanBoxing(){System.out.println("直拳,勾拳,组合拳");}}classBeijingPeopleextendsChinaPeople{publicvoidaverageHeight(){height=172.5;System.out.println("北京人的平均身高:"+height+"厘米");}publicvoidaverageWeight(){we

5、ight=70;System.out.println("北京人的平均体重:"+weight+"千克");}publicvoidbeijingOpera(){System.out.println("花脸,青衣,花旦和老生");}}publicclassExample{publicstaticvoidmain(Stringargs[]){ChinaPeoplechinaPeople=newChinaPeople();AmericanPeopleamericanPeople=newAmericanPeople();Beijing

6、PeoplebeijingPeople=newBeijingPeople();chinaPeople.speakHello();americanPeople.speakHello();beijingPeople.speakHello();chinaPeople.averageHeight();americanPeople.averageHeight();beijingPeople.averageHeight();chinaPeople.averageWeight();americanPeople.averageWeight

7、();beijingPeople.averageWeight();chinaPeople.chinaGongfu();americanPeople.americanBoxing();beijingPeople.beijingOpera();beijingPeople.chinaGongfu();}}银行计算利息classBank{intsavedMoney;intyear;doubleinterest;doubleinterestRate=0.29;publicdoublecomputerInterest(){intere

8、st=year*interestRate*savedMoney;returninterest;}publicvoidsetInterestRate(doublerate){interestRate=rate;}}classConstructionBankextendsBank{doubleyear;pu

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。