JAVE基础实验 Experiment3
Experimental Class 3Java, Ludong University
Exercise 1Make an executable class called Exercise1, with main method write necessary code to display the following:How Day Day Day Day Day many day’s temperatures? 1’s temperature: 78 2’s temperature: 81 3’s temperature: 75 4’s temperature: 79 5’s temperature: 71 76.8 81 71 5
User input Scanner(System.in)
Average temperature: Maximum temperature: Minimum temperature:
Use: Scanner(System.in)& for loop Use an array to store the values
Exercise 2Make a class called Student, with the following elds& methods: age of type integer, private name of type String, private id of type integer, private grade of type double, private one constructor that sets age, name, id, and grade setters and getters for all the private elds Make an executable class called Exercise2, with main method De ne an array of three students:“Zhang”, 21 years old, id 13579, grade of 68.5“Wang”, 19 years old, id 13784, grade of 89.2“Chang”, 20 years old, id 24680, grade of 76.7 display which student is oldest display which student is best in school
Exercise 3 (page 1)Create necessary classes to describe this inheritance“Dog”,“Cat” (to be set by children classes) class Animal int age String type Animal() Animal(int age) void setAge(int age) int getAge() int compareTo(Animal o) void talk() class Dog extends Animal Dog() Dog(int age) void talk() class Cat extends Animal Cat() Cat(int age) void talk() Dog says“WUF-WUF” Cat says“MIEW-MIEW”
use“super”
use“super”
Display the type and age of animal
Exercise 3 (page 2)Make an executable class called Exercise3, with main method create 3 objects of type Animal called animal1, animal2, animal3 assign animal1 type Dog, age 3; increment age using set/get; ask to talk assign animal2 type Cat, age 4; decrement age using set/get; ask to talk ask animal3 to talk display true/false for: 1) animal1 of type Animal; 2) animal2 of type Dog display who is oldest, animal1 or animal2
Dog at age 4 says... WUF-WUF! Cat at age 3 says... MIEW-MIEW! unknown type at age 0 says... animal1 of same type as Animal: true animal2 of same type as Dog: false Comparing animal1 and animal2: 1
The End See you next time!见
…… 此处隐藏:172字,全部文档内容请下载后查看。喜欢就下载吧 ……相关推荐:
- [资格考试]石油钻采专业设备项目可行性研究报告编
- [资格考试]2012-2013学年度第二学期麻风病防治知
- [资格考试]道路勘测设计 绪论
- [资格考试]控烟戒烟知识培训资料
- [资格考试]建设工程安全生产管理(三类人员安全员
- [资格考试]photoshop制作茶叶包装盒步骤平面效果
- [资格考试]授课进度计划表封面(09-10下施工)
- [资格考试]麦肯锡卓越工作方法读后感
- [资格考试]2007年广西区农村信用社招聘考试试题
- [资格考试]软件实施工程师笔试题
- [资格考试]2014年初三数学复习专练第一章 数与式(
- [资格考试]中国糯玉米汁饮料市场发展概况及投资战
- [资格考试]塑钢门窗安装((专项方案)15)
- [资格考试]初中数学答题卡模板2
- [资格考试]2015-2020年中国效率手册行业市场调查
- [资格考试]华北电力大学学习实践活动领导小组办公
- [资格考试]溃疡性结肠炎研究的新进展
- [资格考试]人教版高中语文1—5册(必修)背诵篇目名
- [资格考试]ISO9001-2018质量管理体系最新版标准
- [资格考试]论文之希尔顿酒店集团进入中国的战略研
- 全国中小学生转学申请表
- 《奇迹暖暖》17-支2文学少女小满(9)公
- 2019-2020学年八年级地理下册 第六章
- 2005年高考试题——英语(天津卷)
- 无纺布耐磨测试方法及标准
- 建筑工程施工劳动力安排计划
- (目录)中国中央空调行业市场深度调研分
- 中国期货价格期限结构模型实证分析
- AutoCAD 2016基础教程第2章 AutoCAD基
- 2014-2015学年西城初三期末数学试题及
- 机械加工工艺基础(完整版)
- 归因理论在管理中的应用[1]0
- 突破瓶颈 实现医院可持续发展
- 2014年南京师范大学商学院决策学招生目
- 现浇箱梁支架预压报告
- Excel_2010函数图表入门与实战
- 人教版新课标初中数学 13.1 轴对称 (
- Visual Basic 6.0程序设计教程电子教案
- 2010北京助理工程师考试复习《建筑施工
- 国外5大医疗互联网模式分析




