java实验四云南大学_云南大学java实验6

本次实验旨在让学生熟悉Java中类的继承和抽象类的使用。实验包括创建名为CollegeCourse的类,计算课程费用,并添加Lab子类来处理实验室费用。另外,还设计了一个抽象Auto类,包含汽车制造商和价格字段,其子类Ford和Chevy实现了不同的定价方法。实验结果以程序的形式展示不同汽车的价格。
摘要由CSDN通过智能技术生成

java实验

云南大学软件学院

实 验 报 告

姓名: 学号: 专业: 软件工程 日期: 2014/10/29 成绩: JAVA实验六

一、 实验目的:

熟悉类的继承以及子类、抽象类的使用。会使用子类、抽象类,会使用相关构造方法。 二、 实验要求:

Part1:

Write a program called CollegeCourse that computes the cost of taking a college course. Include a constructor that requires a course ID number.

Add a subclass Lab to compute a lab fee for a course that uses a lab. Write a program UseCourse to use the classes. Save the progras as CollegeCourse, Lab, and UseCourse. Put them all in a package called http://www.wendangwang.comb6. For example, the output could be: The cost of your course is $180.0 there is a $25.00 lab fee.

The cost of your course is $205.0

Part2:

Create an abstract Auto class with fields for the car make and price. Include get and set methods for these fields; the setPrice() method is abstract.

Create two suclasses for individual automobile makers (for example, Ford and Chevy) and include appropriate setPrice() methods in each subclass. Finally, write a program that uses the Auto class and subclasses to display information about different cars. Sample Output:

A new Ford costs $20000.0 A new Chevy costs $22000.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值