Files
javaSE-0113/day06/src/com/inmind/object01/Car.java

57 lines
1.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.inmind.object01;
//标准的javaBean
public class Car {
//属性
private String brand;
private double price;
private String color;
//alt+insert:快速自动生成构造方法getset方法等一系列代码注意功能Fn
//构造方法
public Car() {//无参构造
}
public Car(String brand) {//有参构造
this.brand = brand;
}
public Car(String brand, double price, String color) {//满参构造
this.brand = brand;
this.price = price;
this.color = color;
}
//get/set方法
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
//上面的代码固定的标准的javaBean增加其他的一些成员方法
public void study() {
System.out.println(brand+price+color);
}
}