这是第一个文件,还有另一个文件可以真正解释我的问题;我的问题始于public Account getbankAddress()
方法。
public class Bank {
String bankName;
int bankID;
Address address = new Address();
public Bank(){
bankName = "?";
bankID = 0;
}
public String getBankName(){
return bankName;
}
public int getBankID(){
return bankID;
}
public Address getBankAddress(){
// This is where I'm having trouble getting the bank address from the address class,
// How can I produce a result from the mutator method of setCity and setState methods?
return address;
}
public void setBankName(String bankName1){
bankName = bankName1;
}
public void setBankID(int ID){
bankID = ID;
}
public void setBankAddress(String aCity, String aState){
aCity = "city";
aState = "state";
}
public String toString(){
String str = ("\nBank name:\t\t" + bankName + "\nBank ID:\t\t" + bankID +
"\nBank address:\t\t" + bankAddress + "\n\n");
return str;
}
}
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){
aCity = city;
}
public void setState(String aState){
aState = state;
}
public String toString(){
String str1 = (city + "," + state);
return str1;
}
}