package group5;
/通过抽象类定义车类的模板,然后通过抽象的车类来派生拖拉机、卡车、小轿车。/
abstract class car{
abstract void speed();
abstract void size();
abstract void price();
}
class tractor extends car{
@Override
void speed() {
// TODO Auto-generated method stub
System.out.println("时速10km/h");
}
@Override
void size() {
// TODO Auto-generated method stub
System.out.println("大型车");
}
@Override
void price() {
// TODO Auto-generated method stub
System.out.println("价格偏低");
}
}
class truck extends car{
@Override
void speed() {
// TODO Auto-generated method stub
System.out.println("速度20km/h");
}
@Override
void size() {
// TODO Auto-generated method stub
System.out.println("偏大");
}
@Override
void price() {
// TODO Auto-generated method stub
System.out.println("价格中低水平");
}
}
class sedan extends car{
@Override
void speed() {
// TODO Auto-generated method stub
System.out.println("60km/h");
}
@Override
void size() {
// TODO Auto-generated method stub
System.out.println("体型较小");
}
@Override
void price() {
// TODO Auto-generated method stub
System.out.println("价格中等");
}
}