1.定义一个汽车类(Car),属性有颜色,品牌,车牌号,价格,并实例化两个对象,给属性赋值,并输入属性值
//1.定义一个汽车类(Car),属性有颜色,品牌,车牌号,价格,并实例化两个对象,给属性赋值,并输入属性值
package cu.edu.nefu1;
public class Car {
String color;
String brand;
String ID;
double price;
public static void main(String[] args) {
Car car1 = new Car();
car1.brand = "奥迪";
car1.color = "白色";
car1.ID = "黑A888888";
car1.price = 2341.12;
System.out.println(car1.brand+" "+car1.color+" "+car1.ID+" "+car1.price);
}
}
2.定义一个球员类(Player),属性有身高,体重,姓名,实例化两个球员,分别是姚明和科比;
//2.定义一个球员类(Player),属性有身高,体重,姓名,实例化两个球员,分别是姚明和科比;
package cu.edu.nefu1;
public class