用类去封装花瓶,水壶,对象

来源:百度知道 编辑:UC知道 时间:2024/09/21 22:52:53
怎样用类去封装花瓶,水壶这两个对象?

/*
*花瓶的封装类
*/
public class HuaPing{
private String yanse;//花瓶颜色
private String nianfen;//烤制花瓶年份
private String chandi;//产地
private String price;//价格
public String getChandi() {
return chandi;
}
public void setChandi(String chandi) {
this.chandi = chandi;
}
public String getNianfen() {
return nianfen;
}
public void setNianfen(String nianfen) {
this.nianfen = nianfen;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getYanse() {
return yanse;
}
public void setYanse(String yanse) {
this.yanse = yanse;
}
}

/*
*水壶封装类
*/
public class Shuihu
{
private String cailiao;//水壶材质
private String chandi;//水壶产地
private String jiage;//水壶价格
private String yanse;//水壶颜色
public String getCailiao() {