package 郭申.实验七继承;
public class App_03 {
public static void main(String[] args) {
Bicycle b1=new Bicycle(10,3,5);
Car c1=new Car(8,4,2,7);
System.out.println(b1);
System.out.println(c1);
}
}
class Vehicle{
double speed,weight;
public Vehicle(double speed,double weight) {
this.speed=speed;
this.weight=weight;
}
}
class Bicycle extends Vehicle{
double high;
public Bicycle(double speed,double weight,double high) {
super(speed, weight);
this.high=high;
}
public String toString() {
return "速度:"+speed+",重量:"+weight+"高:"+high;
}
}
class Car extends Bicycle{
private int seatnum;
public Car(double speed,double weight,double high, int seatnum) {
super(speed,weight,high);
this.seatnum=seatnum;
}
public String toString() {
return "速度:"+speed+",重量:"+weight+"高:"+high+",座位数:"+seatnum;
}
}