Here's the prompt guys:
Assignment #4 will be the construction of 2 new classes and a driver program (the class containing a main method).
Address class
The Address class describes cpu of a bank. It has following attributes:
Attribute name Attribute type Description
city String the city of the bank
state String the state of the bank
The following constructor should be provided to initialize each attribute:
public Address()
This constructor initializes city to "?" and city to "?".
The following accessor methods should be provided to get the attributes:
public String getCity()
public String getState()
The following modifier(mutator) methods should be provided to set the attributes:
public void setCity(String aCity)
public void setState(String aState)
The following method must be defined:
public String toString()
The toString() method constructs a string of the following form:
Tempe,AZ
where Tempe is a city and AZ is a state.
Bank class
The Bank class describes a bank that a customer can create an account. It must have the following attributes:
Attribute name Attribute type Description
bankName String The name of the bank
bankID int The ID of the bank
bankAddress Address The address of the bank
The following constructor should be provided to initialize each attribute:
public Bank()
This constructor initializes all strings to "?", all integers to 0, and instantiates an object of Address (i.e., call the constructor of the Address class to create an object of Address). .
The following accessor methods should be provided to get the attributes:
public String getBankName()
pulbic int getBankID()
public Address getBankAddress()
The following mutator methods should be provided to change the attributes:
public void setBankName(String BankName)
public void setBankID(int anID)
public void setBankAddress(String aCity, String aState)
The following method must be defined:
public String toString()
The toString() method constructs a string of the following format:
\nBank name:\t\tBank of Arizona\n
Bank ID:\t\t1005\n
Bank address:\t\tTempe,AZ\n\n
Upon construction the default values for all String attributes should be set to "?", and all integer attributes to 0
Now I've wrote both classes which I've been getting errors with:
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;
}
}
Here's the Bank class:
public class Bank
{
private String bankName;
private int bankID;
private Address bankAddress;
public Bank()
{
bankName = "?";
bankID = 0;
bankAddress = BankAddress(Address);
}
public Bank(String BankName, int anID, String 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 "\n"
+ "Bank ID:\t\t" + bankID "\n"
+ "Bank address:\t\t" + bankAddress "\n\n";
return result;
}
}
Am I doing things right? Please help me, your help will be very much appreciated.
Thanks