helli everyone!!...hope your all in good health...jus wondered if someone could please help me...when i try to compile this code, it says "class or interface expected" for public Bank(String bankName)
i have tried, unsucessfully, to fix this but i dont understand what i have to do.... please can someone help as any help would be greatly appreciated.
public class Bank
{
private String bankName;
private Vector <BankAccount> bankAccounts = new Vector<BankAccount>();
/**
* Constructor for objects of class Bank.
* Newly created banks contain no accounts.
*/
public Bank(String bankName)
{
this.bankName = bankName;
}
public String getBankName()
{
return bankName;
}
/**
* Open a new bank account and return its account number.
* Account numbers are assigned to new accounts automatically:
* the first account created has account number "1", the second
* has account number "2", and so on.
*/
public String openNewAccount(String ownerName, double initialBalance, double overdraftLimit)
{
BankAccount newAccount = new BankAccount(ownerName, initialBalance, overdraftLimit);
bankAccounts.add(newAccount);
return newAccount.getAccountNumber();
}
/**
* If the account exists and has a zero balance,
* remove it from the bank. If it does not exist, or
* does exist but has a non-zero balance, do nothing.
* Note that removing an account has NO effect on the
* account numbers of other accounts, or on the
* automatically allocated account numbers for new
* accounts.
*
* @param accountNumber the account number to remove
*/
public void closeAccount(String accountNumber)
{
for(int i = 0; i < bankAccounts.size(); i++)
{
if(bankAccounts.get(i).getAccountNumber().equals(accountNumber))
{
bankAccounts.remove(i);
break;
}
}
}
/**
* The bank account with the given account number, or null
* if no such account exists.
*
* @param accountNumber the account number
*/
public BankAccount getAccount(String accountNumber)
{
for(int i = 0; i < bankAccounts.size(); i++)
{
if(bankAccounts.get(i).getAccountNumber().equals(accountNumber))
return bankAccounts.get(i);
}
return null;
}
/**
* The value of the total debt of all overdrawn accounts.
* For example, when the bank contains four accounts, with balances
* of 99, -20, -230, 0 then this method returns 250.
*/
public double totalDebt()
{
double debt = 0;
for(int i = 0; i < bankAccounts.size(); i++)
{
if(bankAccounts.get(i).getBalance() < 0)
debt += bankAccounts.get(i).getBalance();
}
return Math.abs(debt);
}
/**
* Print a list of the account numbers and account details
* for all accounts.
*/
public void printAccounts()
{
for(int i = 0; i < bankAccounts.size(); i++)
{
System.out.println("Account Number: " + bankAccounts.get(i).getAccountNumber());
System.out.println("Owner: " + bankAccounts.get(i).getOwnerName());
System.out.println("Balance: " + bankAccounts.get(i).getBalance());
System.out.println("Overdraft Limit: " + bankAccounts.get(i).getOverdraftLimit());
System.out.println("............................................");
}
}
/**
* The total number of accounts in this bank.
*/
public int size()
{
return bankAccounts.size();
}
}
Thank you :D