I'm having a bit of trouble with one of my assignments given to me by my professor. Here is the prompt:
Modify the Customer class to include changeStreetO, changeCityO, changeStateO, and changeZipO methods. Modify the Account class to include a changeAddressO method that has street, city, state, and zip parameters. Modify the Bank application to test the changeAddressO method.
I have the changeStreetO, changeCityO, and changeStateO, and changeZipO. However, I'm confused on the section in bold with the ChangeAddressO method. I think I understand how to write the parameters, but I'm unsure of what is supposed to go within the actual method, and how it fits in with the rest of the program. Here is my current code.
import java.text.NumberFormat;
import java.io.*;
import java.util.*;
public class BankModification
{
public class Account
{
private double balance;
private Customer cust;
public Account(double bal, String fName, String lName, String str, String city, String st, String zip)
{
balance = bal;
cust = new Customer(fName, lName, str, city, st, zip);
/**
* Returns the current balance
* pre: none
* post: The account balance has been returned
*/
}
public double getBalance()
{
return (balance);
}
/**
* A deposit is made to the account
* pre: none
* post: The balance has been increased by the amount of the deposit.
*/
public void deposit(double amt)
{
balance += amt;
/**
* A withdrawal is made from the account if there is enough money
* pre: none
* post: The balance has been decreased by the amount withdrawn.
*/
}
public void withdrawal(double amt)
{
if (amt <= balance)
balance -= amt;
else
System. out. println ("Not enough money in account.");
}
/**
* Returns a String that represents the Account object.
* pre: none
* post: A string representing the Account object has been returned.
*/
public String toString()
{
String accountString;
NumberFormat money = NumberFormat.getCurrencyInstance();
accountString = cust.toString();
accountString += "Current balance is " + money.format (balance);
return (accountString) ;
}
public changeAddressO(String street, String city, String state, zip_)
{
}
public class Customer
{
private String firstName, lastName, street, city,state, zip_;
/**
* constructor
* pre: none
* post: A Customer object has been created.
* Customer data has been initialized with parameters
*/
public Customer(String fName, String lName, String str,
String c, String s, String z)
{
firstName = fName;
lastName = lName;
street = str;
city = c;
state = s;
zip_ = z;
}
/**
* Returns a String that represents the Customer Object
* pre: none
* post: A string representing the Account object has been returned.
*/
public String toString()
{
String custString;
custString=firstName + " " + lastName + "\n";
custString +=street + "\n";
custString += city + ", "+state+ " " + zip_ + "\n";
return(custString);
}
public void ChangeStreetO(String newStreet)
{
street = newStreet;
}
public void ChangeCityO(String newCity)
{
city = newCity;
}
public void ChangeStateO(String newState)
{
state = newState;
}
public void ChangeZipO(String newZip)
{
zip_ = newZip;
}
}
}
}
I'm not sure if I'm missing something essential, but without the changeAddressO method, the program compiles. I'm simply unable to figure out what I need to put in the changeAddressO since I made methods with the chageStreetO, changeCityO, changeStateO, and changeZipO. I'm still having a bit of difficulty with classes and methods. Could someone provide some insight/guidance to help figure out this problem? Thank you for your time.