我有 2 个相互扩展的类。我有一个调用类 Address.Java 以从类中获取城市和州的 mutator 方法。但是 Bank.java 类给我带来了问题。给我带来问题的具体方法是
public void setBankAddress(String aCity,String aState)(代码如下)我不知道这是否有意义{
}
银行.Java
public class Bank
{
private String bankName;
private int bankID;
private Address bankAddress;
public Bank()
{
bankName = "?";
bankID = 0;
bankAddress = new Address();
}
public String getBankName()
{
return bankName;
}
public int getBankID()
{
return bankID;
}
public Address getBankAddress()
{
return bankAddress;
}
public void setBankName(String aBankName)
{
bankName = aBankName;
}
public void setBankID(int aBankID)
{
bankID = aBankID;
}
public void setBankAddress(String aCity, String aState)
{
}
public String toString()
{
return "\nBank name:\t\t" + bankName + "\nBank ID:\t\t" + bankID + "\nBank Address:\t\t" + bankAddress + "\n\n";
}
}
地址。爪哇
public class Address
{
private String city;
private String state;
public Address()
{
city = "?";
state = "?";
}
public String getCity()
{
return city;
}
public String getState()
{
return state;
}
public void setCity(String aCity)
{
city = aCity;
}
public void setState(String aState)
{
state = aState;
}
public String toString()
{
return city + "," + state;
}
}