JAVA代码交通工具选择 java定义交通工具类( 二 )


@Override
public void start(String flag) {
System.err.println("我是用" + flag);
}
@Override
public void stop() {
}
}
JAVA入门题,设计一个交通工具类Vehicle,它具有如下属性class Vehicle {
int Speed;
public String getKind() {
return Kind;
}
public void setSpeed(int speed) {
Speed = speed;
}
public void setColor(String color) {
Color = color;
}
public void setKind(String kind) {
Kind = kind;
}
String Kind;
String Color;
public String getColor() {
return Color;
}
public Vehicle() {
// 默认构造方法
}
public Vehicle(int Speed, String Kind, String Color) {
this.Speed = Speed;
this.Kind = Kind;
this.Color = Color;
}
}
class Car extends Vehicle {
private int passenger;
public int getPassenger() {
return passenger;
}
public void setPassenger(int passenger) {
this.passenger = passenger;
}
public Car() {
// 默认构造方法
}
public Car(int Speed, String Kind, String Color, int passenger) {
this.Speed = Speed;
this.Kind = Kind;
this.Color = Color;
this.passenger = passenger;
}
}
class Demo {
public static void main(String[] args) {
Car car =new Car(120,"宝马","红",5);
car.setSpeed(160);
car.setColor("黄");
car.setKind("奥迪");
System.out.print(car.getKind()+"\t"+car.getColor()+"\t"+car.Speed+"\t"+car.getPassenger());
}
}
JAVA代码交通工具选择的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于java定义交通工具类、JAVA代码交通工具选择的信息别忘了在本站进行查找喔 。

推荐阅读