/**
* Write a description of class BankAccount here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class BankAccount
{
private int balance;
private String accountName;
public BankAccount(String name)
{
accountName = name;
balance = 0;
}
public BankAccount(String name, int newBalance)
{
accountName = name;
balance = newBalance;
}
/**
* Changes accountName
* @param used to change the account name, changing
* what accountName was set to to a new variable
*/
public void setName(String name)
{
accountName = name;
}
/**
* Adds money to account
* @param used to update the balance of the account
* by adding to it
*/
public void addBalance(int moreBalance)
{
if(moreBalance >= 0)
{
balance += moreBalance;
}
}
/**
* Gets the account name
* @param used to return accountName
*/
public String getName()
{
return accountName;
}
/**
* Get the balance
* @param used to return balance
*/
public int getBalance()
{
return balance;
}
/**
* Withdraws money from account
* @param used to withdraw money from balance
*/
public void withdrawFromAccount(int withdrawAmount)
{
if(withdrawAmount >=0 && withdrawAmount <= balance)
{
balance -= withdrawAmount;
}
}
public String toString() {
return "Account for: "+accountName+" Balance: $"+balance;
}
}