我有这个问题,这是给我的图表,我已经设法提出了一个解决方案,但实际问题本身是要求我实现 get 和 set 方法,我不确定它们是否适用于这里,
这只是一个有点长的问题的一部分,不想让它看起来像我希望用户在这里通过粘贴整个问题来完成我的作业,但只是一个疑问,如果确实可以实现 get 和 set 方法怎么能我这样做?
所以这是我的代码,到目前为止我所拥有的
public abstract class Property
{
private static int autonumber = 0, propID,area,price;
private String address;
public Property(String addr, int area,int price)
{
autonumber++;
propID = autonumber;
this.area = area;
this.price = price;
}
public abstract double calculateMiscFee();
public int getArea()
{
return area;
}
public void setArea()
{
}
// public double calculateMiscFee()
// {
// return 100*
// }
}
这是我拥有的最新代码
public abstract class Property
{
private static int autonumber = 0;
private int propID;
private int area;
private double price;
private String address;
private int district;
public Property(String addr, int area,double price, int district)
{
autonumber++;
propID = autonumber;
this.area = area;
this.price = price;
this.district = district;
this.address = addr;
}
public abstract double calculateMiscFee();
public int getArea()
{
return area;
}
public void setArea(int a)
{
area = a;
}
public String getAddress()
{
return address;
}
public void setAddress(String add)
{
address = add;
}
public double getPrice()
{
return price;
}
public void setPrice(double p)
{
price = p;
}
public int getDistrict()
{
return district;
}
public void setDistrict(int disc)
{
district = disc;
}
// public double calculateMiscFee()
// {
// return 100*
// }
public String toString()
{
}
}