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