JAVA编程小问题找高人救命啊!

来源:百度知道 编辑:UC知道 时间:2024/06/27 06:16:00
创建一个汽车类CarModel.java,它里面有2个不同的构造函数,CarManufactory.java可以应用这些构造方法创建不同类型的汽车
CarModel.java设计要求如下:
定义style(String),color(String),category(String)注:括号中为变量类型
创建第一个构造函数,分别给以上变量赋值,要求为该构造函数定义三个形参,分别赋给相应的变量,形参的值在对象创建时给出
创建第二个构造函数,此构造函数过程为空
定义三个方法,分别返回style,color,category的值
CarManufactory.java设计要求如下:
使用不同的构造函数创建两辆汽车
显示两辆车相关的属性,属性的值要从CarModel的相关方法中取出

public class Car{
String style;
String color;
String category;

public Car(String style,String color,String category){
this.style=style;
this.color=color;
this.category=category;
}
public Car(){
}

public String getStyle() {
return (this.style);
}

public void setStyle(String style) {
this.style = style;
}

public String getColor() {
return (this.color);
}

public void setColor(String color) {
this.color = color;
}

public String getCategory() {
return (this.category);
}

public void setCategory(String category) {
this.category = category;
}

}
class CarManufactory{
public static void main(String [] args){

Car car=new Car("aa","bb","cc");
System.out.println (car.getStyle()+" "+car.getColor(