class Test_Phone {
public static void main(String[] args) {
Phone p = new Phone();
p.setBrand("酷派");
p.setPrice(5000);
System.out.println(p.getBrand()+",,,,"+p.getPrice());
Phone p1 = new Phone("酷派",5000);
p1.show();
}
}
class Phone {
private String brand;
private int price;
public Phone(){
return;
}
public void Phone(String brand,int price){
this.brand=brand;
this.price=price;
}
public void setBrand(String brand){
this.brand=brand;
}
public String getBrand(){
return brand;
}
public void setPrice(int price){
this.price=price;
}
public int getPrice(){
return price;
}
public void show(){
System.out.println("手机品牌是:"+brand+",手机价格为"+price);
}
} |
|