通过抽象类定义车类的模板,然后通过抽象的车类来派生拖拉机、卡车、小轿车5-1

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("价格中等");
}

}

上一篇:c – 自动生成功能存根


下一篇:【python】python GUI开发框架介绍