




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 学 生 实 验 报 告 册(理工类)课程名称:专业班级:学生姓名:指导教师:学生学号:所属院部:2020学年第 学期金陵科技学院教务处制 实验报告书写要求实验报告原则上要求学生手写,要求书写工整。若因课程特点需打印的,标题采用四号黑体,正文采用小四号宋体,单倍行距。纸张一律采用 A4 的纸张。实验报告书写说明实验报告中实验目的和要求、实验仪器和设备、实验内容与过程、实验结果与分析这四项内容为必需项。教师可根据学科特点和实验具体要求增加项目。填写注意事项(1)细致观察,及时、准确、如实记录。(2)准确说明,层次清晰。(3)尽量采用专用术语来说明事物。(4)外文、符号、公式要准确,应使用统一规定
2、的名词和符号。(5)应独立完成实验报告的书写,严禁抄袭、复印,一经发现,以零分论处。实验报告批改说明实验报告的批改要及时、认真、仔细,一律用红色笔批改。实验报告的批改成绩采用五级记分制或百分制,按金陵科技学院课堂教学实施细则中作业批阅成绩评定要求执行。实验报告装订要求实验批改完毕后,任课老师将每门课程的每个实验项目的实验报告以自然班为单位、按学号升序排列,装订成册,并附上一份该门课程的实验大纲。 金陵科技学院实验报告实验项目名称: 面向对象编程实验 实验学时:8同组学生姓名:实验日期:实验地点:实验成绩:批改时间:批改教师: 金陵科技学院实验报告实验 1 面向对象编程实验一、实验目的和要求(1
3、)理解 Java概念、掌握 JDK环境配置(2)熟悉 Java开发过程(3)掌握 Java面向对象编程基础:封装、继承、多态(4)掌握 Java接口编程,理解开发模式二、实验仪器和设备奔腾以上个人计算机, windows操作系统。配置好 JDK环境,安装集成开发环境(Eclipse)三、实验内容与过程1、JDK环境配置2、面向对象的封装性范例:设计一个表示学生的类,里面有学生的三项成绩:计算机成绩、数学成绩、英语成绩。要求可以求总分、平均分、最高分、最低分,并且可以输出一个学生的完整信息。 代码如下:class Studentprivate String name ;private int a
4、ge ;private float english ;private float computer ;private float math ;public Student()public Student(String n,int a,float e,float c,float m)this.setName(n) ;this.setAge(a) ;this.setEnglish(e) ;this.setComputer(c) ;this.setMath(m) ;public float sum()return english + computer + math ;public float avg
5、()return this.sum() / 3 ;public float max()float max = computermath?computer:math ;max = maxenglish?max:english ;return max ;public float min()float min = computermath?computer:math ;min = min0)/ 用于保存下一个的记录点this.temp = new intlen ; / 此时大小由外部决定elsethis.temp = new int1 ;/ 至少开辟一个空间public boolean add(in
6、t i)/ 加入数据操作if(this.footthis.temp.length) / 还有空位this.tempthis.foot = i ; / 加入内容this.foot+ ; / 改变长度return true ; / 加入成功返回 trueelsereturn false ;/ 加入失败public int getArray() / 返回全部的数组return this.temp ; 金陵科技学院实验报告class SortArray extends Arraypublic SortArray(int len)super(len) ;public int getArray()java
7、.util.Arrays.sort(super.getArray() ; / 排序操作return super.getArray() ; / 返回的是排序后的内容class ReverseArray extends Arraypublic ReverseArray(int len)super(len) ;public int getArray()int rt = new intsuper.getArray().length ;/ 根据大小开辟新数组int count = rt.length-1 ;for(int x=0;xsuper.getArray().length;x+)rtcount =
8、 super.getArray()x ;count- ;return rt ;public class ArrayDemopublic static void main(String args)ReverseArray arr = new ReverseArray(6) ;System.out.println(arr.add(3) ;System.out.println(arr.add(23) ;System.out.println(arr.add(1) ;System.out.println(arr.add(5) ;System.out.println(arr.add(6) ;System.
9、out.println(arr.add(8) ;System.out.println(arr.add(11) ;System.out.println(arr.add(16) ;print(arr.getArray() ;public static void print(int i)for(int x=0;xi.length;x+)System.out.print(ix + 、) ;对照范例写出如下题目: 金陵科技学院实验报告(1). 创建 GrandFather类,其中包括a) 属性:姓名(name),年龄(age)b) 方法 getGrandFather():显示爷爷的信息c) 构造方法:给
10、爷爷的姓名,年龄赋值(2). 创建 Father类,继承 Grandfather类a) 属性:除了继承爷爷的属性以外,还要增加自己的属性:“职业”(occupation)b) 构造方法:显式调用 GrandFather类的构造方法,为 GrandFather类的姓名和年龄赋初始值。再为自己职业输入初始值。c) 方法 getFather(): 显式调用 GrandFather类的 getGrandFather(),再显示父亲的相关信息 String返回值(3). 创建主类,定义 main()方法,构造 GrandFather类的对象和 Father类的对象,并分别显示详细信息。System.ou
11、t.println思考:覆盖 将父类和子类的显示信息函数,写成统一的 getInfo3、面向对象多态性范例:计算柱体的体积。柱体体积计算公式是:底部面积乘以高度柱体底部分为 圆形和矩形要求:通过抽象类和多态实现package cn.jit.demo;abstract class Bottom /父类抽象类 底部public abstract double calculatorArea();class CircleBottom extends Bottom/圆形底/* 半径*/private double radius;Overridepublic double calculatorArea()
12、 return Math.PI * radius * radius;public double getRadius() return radius;public void setRadius(double radius) this.radius = radius;public CircleBottom(double radius) super();this.radius = radius;class SquareBottom extends Bottom/矩形底 金陵科技学院实验报告private double sideA;private double sideB;public double
13、getSideA() return sideA;public void setSideA(double sideA) this.sideA = sideA;public double getSideB() return sideB;public void setSideB(double sideB) this.sideB = sideB;Overridepublic double calculatorArea() return sideA * sideB;public SquareBottom(double sideA, double sideB) super();this.sideA = s
14、ideA;this.sideB = sideB;class ZhuTi /柱体类,完成形状的拼装/* 底*/private Bottom bottom;/* 高*/private double height;/* 计算体积* return*/public double calculatorVolumn()return bottom.calculatorArea() * height;public ZhuTi(Bottom bottom, double height) super();this.bottom = bottom; 金陵科技学院实验报告this.height = height;pub
15、lic Bottom getBottom() return bottom;public void setBottom(Bottom bottom) this.bottom = bottom;public double getHeight() return height;public void setHeight(double height) this.height = height;public void changeBottom(Bottom bottom)this.bottom = bottom;public class VolumnTest /测试类public static void
16、main(String args) Bottom bottom = new CircleBottom(1.0);double height = 1.0;ZhuTi zhuTi = new ZhuTi(bottom,height);double result = zhuTi.calculatorVolumn();System.out.println(圆柱体的体积是: + result);bottom = new SquareBottom(1.0,1.0);zhuTi.changeBottom(bottom);result = zhuTi.calculatorVolumn();System.out
17、.println(立方体的体积是: + result);范例:接口和多态的应用,例如:电脑上实现了 USB接口,U盘,打印机等等也都实现了此标准。interface USBpublic void start() ;/ 开始工作public void stop() ; / 结束工作class Computerpublic static void plugin(USB usb)usb.start() ;usb.stop() ;class Flash implements USB 金陵科技学院实验报告public void start()System.out.println(U盘开始工作。) ;pu
18、blic void stop()System.out.println(U盘停止工作。) ;class Print implements USBpublic void start()System.out.println(打印机开始工作。) ;public void stop()System.out.println(打印机停止工作。) ;public class InterPolDemo02public static void main(String args)Computer.plugin(new Flash() ;Computer.plugin(new Print() ;对照范例,写出以下程序
19、:(1) 乐器(Instrument)的标准为弹奏(play),而乐器类型分为:钢琴(Piano)和小提琴(Violin),各种乐器的弹奏方法各不同。编写代码实现不同乐器的弹奏。(2) 计算机模拟四、实验结果与分析(程序运行结果及其分析)五、实验体会 金陵科技学院实验报告实验项目名称:同组学生姓名:实验日期:类集实验学时:4实验地点:实验成绩:批改时间:批改教师: 金陵科技学院实验报告实验 2 类集一、实验目的和要求(1)理解类集概念(2)熟悉 Collection接口、List接口、Set接口和 Map接口(3)掌握 ArrayList类、HashSet类和 TreeSet类(4)理解 Tr
20、eeMap、HashMap二、实验仪器和设备奔腾以上个人计算机, windows操作系统。配置好 JDK环境,安装集成开发环境(Eclipse)三、实验内容与过程1、类集应用范例:实现一个超市管理系统,要求可以添加货物,删除货物和查询货物:。 代码如下:public interface Goods public String getName(); / 得到商品名称public int getCount(); / 得到商品数量public float getPrice(); / 得到商品价格public class Book implements Goods private String nam
21、e;private int count;private float price;public Book() public Book(String name, int count, float price) = name;this.count = count;this.price = price;public String getName() return name;public void setName(String name) = name; 金陵科技学院实验报告public int getCount() return count;public voi
22、d setCount(int count) this.count = count;public float getPrice() return price;public void setPrice(float price) this.price = price;public boolean equals(Object obj) if (this = obj) return true;if (!(obj instanceof Book) return false;Book b = (Book) obj;if (.equals() & b.count = this.c
23、ount& b.price = this.price) return true; else return false;public int hashCode() return .hashCode() + new Integer(this.count).hashCode()+ new Float(this.price).hashCode();public String toString() return 书名: + + ;书的价格: + this.price + ;书的数量:+ this.count; 金陵科技学院实验报告import java.util.A
24、rrayList;import java.util.Iterator;import java.util.List;public class SuperMarket private List allGoods;public SuperMarket() this.allGoods = new ArrayList();public void add(Goods goods) this.allGoods.add(goods);public void remove(Goods goods) this.allGoods.remove(goods);public List search(String key
25、Word) List temp = new ArrayList();Iterator iter = this.allGoods.iterator();while (iter.hasNext() Goods g = iter.next();if (g.getName().indexOf(keyWord) != -1) temp.add(g);return temp;public List getAllGoods() return this.allGoods;import java.util.Iterator;import java.util.List;public class Test 金陵科技
26、学院实验报告public static void main(String args) SuperMarket mak = new SuperMarket();mak.add(new Book(Java, 2, 30.9f);mak.add(new Book(C+, 3, 10.9f);mak.add(new Book(JSP, 5, 80.9f);print(mak.search(J) ;mak.remove(new Book(Java, 2, 30.9f) ;print(mak.search(J) ;public static void print(List all) Iterator it
27、er = all.iterator();while (iter.hasNext() System.out.println(iter.next();对照范例写出如下题目:(1)宠物商店,要求可以添加、删除和查找宠物(2)实现以下两个关系A、一个学校可以有多个学生,所有学生属于一个学校B、一门课程可以有多个学生选,一个学生可以选多门课程四、实验结果与分析(程序运行结果及其分析)五、实验体会 金陵科技学院实验报告实验项目名称: Java IO操作实验学时:实验地点:实验成绩:批改时间:6同组学生姓名:实验日期:批改教师: 金陵科技学院实验报告Java IO 操作实验 3一、实验目的和要求(1)理解输入输出流概念(2)掌握文件输入输出流(3)掌握键盘的输入、显示器的输出(4)理解其他输入输出流二、实验仪器和设备奔腾以上个人计算机, windows操作系统。配置好 JDK环境,安装集成开发环境(Eclipse)三、实验内容与过程1、编写类模拟命令 Copy范例:实现文件的复制代码。 参考代码如下:File file1 = new File(“d:”+File.seperator +”demo.txt”);/
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 现代职场题材电影的传播与影响分析报告
- 污水接管合同范本
- 公厕设计合同范本
- 文化创意产品设计服务合同
- 科技创新企业通过服务质量提高产品信赖度研究
- 2025年玉米免耕播种机合作协议书
- 科技创新驱动下的电动汽车行业发展
- 电能质量监测技术在通信网络中的应用
- 2025年度棒球场场地租赁与赛事赞助协议
- 科技企业如何构建知识产权护城河
- 工业CT发展及应用课件
- DBJ50∕T-098-2019 城市绿化养护质量标准
- 自动化腹膜透析(APD)的临床应用课件
- (日文文书模板范例)请求书-请求书
- 旅游消费者行为学整套课件完整版电子教案课件汇总(最新)
- 学前儿童发展心理学(第3版-张永红)教学课件1754
- 2022牛排消费趋势报告
- TPM╲t4Step Manul(三星TPM绝密资料)
- 细菌群体感应系统及其应用课件
- 司法鉴定程序通则(试行)
- 通达信指标——江恩轮
评论
0/150
提交评论