I got stuck at this error:
cannot find symbol
symbol: variable BankAddress
location: class Bank
bankAddress = BankAddress; <------pointing at BankAddress;
I'm trying to instantiate an object of Address, calling the constructor of the Address class to create an object of Address.
I'll post both classes, Bank and Address
Address class
public class Address
{
private String city;
private String state;
public Address()
{
city = "?";
state = "?";
}
public Address(String aCity, String aState)
{
city = aCity;
state = aState;
}
public String getCity()
{
return city;
}
public void setCity(String aCity)
{
city = aCity;
}
public String getState()
{
return state;
}
public void setState(String aState)
{
state = aState;
}
public String toString()
{
String result;
result = city + "," + state;
return result;
}
}
Bank class
public class Bank
{
private String bankName;
private int bankID;
private Address bankAddress;
public Bank()
{
bankName = "?";
bankID = 0;
Address bankAddress = new Address();
}
public Bank(String BankName, int anID, Address BankAddress)
{
bankName = BankName;
bankID = anID;
bankAddress = BankAddress;
}
public String getBankName()
{
return bankName;
}
public void setBankName(String BankName)
{
bankName = BankName;
}
public int getBankID()
{
return bankID;
}
public void setBankID(int anID)
{
bankID = anID;
}
public Address getBankAddress()
{
return bankAddress;
}
public void setBankAddress(String aCity, String aState)
{
bankAddress = BankAddress;
}
public String toString()
{
String result;
result = "Bank name:\t\t" + bankName
+ "Bank ID:\t\t" + bankID
+ "Bank address:\t\t" + bankAddress;
return result;
}
}
I'm not sure what's wrong, I've been trying for the past hour now. It's so confusing.