public class Car1 extends Car {
public String manufacturer;
public Car1(String color, String style, String manufacturer) {
super(color, style);
this.manufacturer = manufacturer;
}
public Car1(String color) {
this.color = color;
this.manufacturer = "
上海大众";
}
@Override
public String toString() {
return "Car1 [manufacturer=" + manufacturer + ", color=" + color + ", style=" + style + "]";
}
public Car1() {
super();
}
public static void main(String[] args) {
Car1 a = new Car1();
Car1 b = new Car1("黑色", "卡车", "斯泰尔");
Car1 c = new Car1("白色");
System.out.println(a.toString());
System.out.println(b.toString());
System.out.println(c.toString());
}
}
class Car {
public String color;
public String style;
public Car() {
this.color = "red";
this.style = "car";
}
public Car(String color, String style) {
this.color = color;
this.style = style;
}
public void showColor() {
System.out.println("颜色 " + this.color);
}
public void showStyle() {
System.out.println("型号 " + this.style);
}
}