CoreJava/exp3/Vehicle.java
2024-05-09 09:10:51 +08:00

28 lines
662 B
Java

package exp3;
public class Vehicle {
//成员属性
String brand; //品牌
int wheels; //车轮数
float weight; //重量
public Vehicle(){
this.brand = "无品牌";
this.wheels = 0;
this.weight = 0;
}
public Vehicle(String brand, int wheels, float weight){
this.brand = brand;
this.wheels = wheels;
this.weight = weight;
}
void show(){
System.out.println("enter super class method...");
System.out.println("品牌: "+this.brand);
System.out.println("车轮数: "+this.wheels);
System.out.println("重量: "+this.weight);
}
}