




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、信息工程学院1Java程序设计 实习报告成绩:Java学院:信息工程学院班级:姓名:学号:1. 实验目的掌握Java程序面向对象编程的基本架构,会运用面向对象的思想编写程序。2. 实验过程熟悉JAVA的编程环境实验题1阅读如下程序,完成思考题。class CCircle double pi;double radius;double getRadius()T Pro blurns Javadcc匮Deterrn inated?car Java Applicati Problems0 Javadoc鱼 Deck ration 1 旦 Console 冥、terminated car Java Ap
2、plication C:Pr0gr3m Fil?sJav3jdkl,5.0birjavaw.ibefare step eai:g二w Qu丄匚ng tQ;new che speed :35 0new the car ngle is:0.0 stop cazthis cars belong to:zhangyong now the speed 3:0 0now ttie car ngle Id ; 0 0实验报告的内容与格式按任课教师的要求书写。异 Problems闻 JavadocDe-chration 1 terminatedMyprogrem Jaw己 Appli匚artionbefore
3、 change the values:15zhangyangchange the values:2&asdf豐1 Problems 和,Javadoc 匱 Declaration B 匚oncole 滋 bankaccount Java Application C:Program File-sJavajdkl.6r0_32bir 刍952452533 21146591岂HEE佥琶务5&06.0甘一29醐云三張旺再2G0&0.011500元百杀丘为14500.0匕 Problems Javadoc L Deelar atior 旦 Con sole- 3terrninated link Java
4、 Application C:Progrann Fi I e sJ a vsj d kl. 6 0_32 b i nja vow. e-x湮电兰議战兰:1Ink Is empty:堆人余疗?:5W32说尹驚津点:321M主芝占丰対二1台=2至耘知:1庄壬左*列壬矍拎4raw();程序源代码如下:Shape 类: public class shape void draw()void erase()public shape() raw(); 程序运行结果如下:Pr&b I em 呂 Jwadocf 皐 shpe Java Appli匚atioCircle* dratf()drclE_draw()C
5、ircle.draw()square. dra()Circle,draw()Triangle.draw()Triangle.draw()Circle.dra()square dr3w()实验题2 有两个类:MobileManagement和Mobile,分别描述如图所示两部手 机名称及价格,类MobileManagement在包中,而Mobile在包中。它们代码如下。 运行,你应该看到如图所示结果。基本要求在空白处填写相关代码并修改上面程序,使程序能够显示两部手机的价格和数量,运行结果如图所示。E365, 1780 RMBM330, 1450 RMB图手机及价格图Mobile phones:图
6、运行结果图 程序源代码如下:下的 MobileManagement类:package class MobileMa nageme nt /* Defines the entry point of the application. */ public static void main(String args) Mobile mobile1 = new Mobile(E365, 1780);Mobile mobile2 = new Mobile(M330, 1450);(n ull, Mobile pho nes:nn+()+n+();下的Mobile 类:package class Mobile
7、 /* Holds the n ame of the mobile. */ private String name;/* Holds the price of the mobile. */ private float price;/* Creates a new mobile object. */ public Mobile(String name, float price) =n ame;=price;/* Gets the n ame of the mobile. */public Stri ng getName() return n ame;/* Gets the price of th
8、e mobile. */ public float getPrice() return price;运行结果如下:实验题3 有四个类,主类 Store在包中,Mobile、Mp3Player、Product 在包中,Mobile、Mp3Player 是 Product 的子类.基本要求设计类Mobile和类MP3Player,使它们和类 Product、Store 组成一个完整的程序,且运行结果如图所示。程序源码如下:中 Product 类:package abstract class Prouduct impleme nts Comparable /* Holds the n ame of
9、the product. */protected Stri ng n ame;/* Holds the price of the product. */protected float price;/* Holds the n umber of products. */protected static int cou nt;/* Create a new product object. */protected Prouduct() /* Gets the n ame of the product. */public Stri ng getName() return n ame;/* Gets t
10、he price of the product. */public float getPrice() return price;/* Gets the number of products. */ public static int getCount() return count;/* Compares this product with the given product. */ public int compareTo(Prouduct product) return new Float()pareTo(price);中 Mp3Player 类: package class MP3play
11、er extends Prouduct private String name;private float price; private int memory;public MP3player(String name,int memory,float price) */ public static void main(String args) E365,1780);Play,256, 930);Mobile mobile1 = new Mobile(China Mobile, Mobile mobile2 = new Mobile(China Mobile, M330,1450); MP3pl
12、ayer player1 = new MP3player(Meizo X3, 256, 399); MP3player player2 = new MP3player(Meizo E5, 512, 580); MP3player player3 = new MP3player(Xlive XM MP3 Prouduct prouducts=mobile1,mobile2,player1,player2, player3;(prouducts); String text = ;for(int index = 0; index ; +index) text += prouductsindex.to
13、String()+n;(null,The products are:nn+text+nThere are +()+ products.); 程序运行结果如下:The prcxlucts art;E365 on China Mobile, 1780.0 RMB r.1330 Ml China Mobile, 1450.0 RUB Meizo X3 String n ame;Stri ng ID;public Pers on() 【二 Problems伍 Javadoc*: DeclarationS Console 盘 Lkt Java Application匚AProgrsm FilesJ3va
14、jdlcl.6.0_3Abinjavav 老客報三宙丹爭1231000建客:1232&0G78-0 具谱戒里匚 S9.0 蛊学聽呕 39.0社客 星玄婆訐圧号1254345S0工空6765.0public class MAP public MAP( ) terator();terminated hash set Java Appli 匚 nticjn匚;Prcgram Fi lesJavajd kl.6.Q_32birijava wexe 區需 季巨畠沙哙1232006 S3=罢兰再注吃:1231000, :茎亘*沖心:1233&0*L Problemsdvadoc風 DeclaraticMAP Java Application匚:、: 12 &024. w苑:12W25.它!:盏匚歩12&02612&027L2002S.芒省TCf12&02S-芒屯;兰雯氓120017,L2W18.12&01512&026.12 &021.芒起:宜段整H号12M22-120023-它宕:宝肓勇爭号12W0S爭号12W8 爲査您;云年囲12&611-SB12&016.壬走:吧土惨L2M13-芒运:至滾早学号120012,左总:益M壬129015.建名云右”12&01412&001-启笔:T.P?ffl事令L2&M3.迂區:芸X12&02.字号12&05r芒芒;直更勇12G&O4.12&007s
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 小说结构及其分析试题及答案
- 计算机一级Msoffice知识技能考核试题及答案
- 前端技能测试题及答案揭秘
- 公司的竞争优势与战略创新试题及答案
- 2025年税法考试专题试题及答案
- 2025年普通逻辑考试的选择与准备试题及答案
- 快消品包装2025:绿色包装与品牌形象塑造策略研究
- 2025年商业银行金融科技人才可持续发展战略研究报告
- 2025年资产评估税法试题及答案
- 2025年农产品电商市场前景与农村电商生态构建策略研究报告
- 马尔代夫旅游介绍
- 保险行业档案管理培训
- 无废城市知识培训课件
- 2025煤炭矿区水土保持监测技术服务合同书
- 五金产品购销合同清单
- 2024年全国高中数学联赛(四川预赛)试题含答案
- 东北三省精准教学联盟2024-2025学年高三下学期3月联考地理试题(含答案)
- 2024北京西城区初一(下)期末道法试题和答案
- 空调安装施工方案
- 英语-湖北省武汉市2025届高中毕业生二月调研考试(武汉二调)试题和答案
- 静脉留置针留置护理
评论
0/150
提交评论