lass Car{
private String brand;//品牌
private String type;//颜色
private String money;//价格
//空参
public Car(){
System.out.println("无参方法被调用");
}
//重写构造函数
public Car(String b,String t,String m){
this.brand = b;
this.type = t;
this.money = m;
}
//显示信息
public void show(){
System.out.println("品牌为:"+this.brand+" 颜色为:"+this.type+"尺寸为:"+this.money);
}
public void run(){
System.out.println("汽车跑了");
}
}
//测试类
public class QIChe {
public static void main(String[] args){
Car c = new Car("BugattiChiron","红色","3000K $");//初始化信息
c.show();
c.run();
}
}