Hi all. How's everybody doing? Good I hope. I'm hanging in there.
What I have are some classes for a program I'm sure many of you have seen before, ye ol' BankAccount class. What I've done here is write a subclass that inherits from the the BA class. But the subclass doesn't compile and I can't figure out what to do. I keep getting the error below:
SavingsAccount.java:10: error: no suitable constructor found for BankAccount(String,String)
super(CName, CType);
^
constructor BankAccount.BankAccount(int,String,String,String,d ouble,double) is not applicable
(actual and formal argument lists differ in length)
constructor BankAccount.BankAccount() is not applicable
(actual and formal argument lists differ in length)
1 error
Below are the classes I've written. If anyone can point me in the right direction, it would be much appreciated.
import java.util.*; import java.io.*; import java.text.DecimalFormat; class BankAccount { private int AccountNumber; private String AccountType; String CustName; // Made these two public String CustType; private double Balance; private double MonthlyFee; private static int NumberOfBankAccounts = 0; BankAccount() { AccountNumber = 0; AccountType = ""; CustName =""; CustType=""; Balance =0.0; MonthlyFee = 0.0; } BankAccount(int AccNum, String AccType, String CName, String CType, double Bal, double mFee) { AccountNumber = AccNum; AccountType = AccType; CustName = CName; CustType = CType; Balance = Bal; MonthlyFee = mFee; } public int getAccountNumber() { return AccountNumber; } public void setAccountNumber(int accNum) { AccountNumber = accNum; } public String getAccountType() { return AccountType; } public void setAccountType(String accType) { AccountType = accType; } public String getCustName() { return CustName; } public void setCustName(String cName) { CustName = cName; } public String getCustType() { return CustName; } public void setCustType(String cType) { CustType = cType; } public double getBalance() { return Balance; } public void setBalance(double bal) { Balance = bal; } public double getMonthlyFee() { return MonthlyFee; } public void setMonthlyFee(double mFee) { MonthlyFee = mFee; } public static void incrementBankAccountNumber() { NumberOfBankAccounts++; } public String toString() { DecimalFormat formatter2 = new DecimalFormat("#0.00"); return "Account #: " + AccountNumber + " Account Type: " + AccountType + " Customer Name: " + CustName + " Customer Type: " + CustType + " Balance: $" + Balance + " Monthly Fee: $" + formatter2.format(MonthlyFee); } }
class SavingsAccount extends BankAccount { private double savingsNumber; private double savingsBalance; public SavingsAccount(){} public SavingsAccount(String CName, String CType, double savNum, double savBal) //Not sure if CType is the arg needed. { super(CName, CType); savingsNumber = savNum; savingsBalance = savBal; } public void setsavingsNumber(double savNum) { savingsNumber = savNum; } public void setsavingsBalance(double savBal) { savingsBalance = savBal; } public double getsavingsNumber() { return savingsNumber; } public double getsavingsBalance() { return savingsBalance; } public String toString() { String str = "Customer: " + super.getCustName() + "\n, has a current savings balance of: " + savingsBalance; return str; } }