Hi guys, I need some help here. I am going to put all of my classes so that I can get a feedback on each one and to tell m exactly what I am missing, because it is not running like the way it supposed to do so here goes nothing
this is the customer class
this is the account abstract class
this is the transaction_account class
this is the saving_account class
this is the chequing_account class
and this is the bank account class which is the main, aint finish it as yet but when i gave it a test run,
yea when ah gave it a test run run this is the result
public class Customer { private String first_name; private String last_name; private String email_add; private String home_add; private String telephone; public String getfirt_name(){ return this.first_name; } public String getlast_name(){ return this.last_name; } public String getemail_add(){ return this.email_add; } public String gethome_add(){ return this.home_add; } public String gettelephone(){ return this.telephone; } public void setfirst_name(String first_name){ this.first_name=first_name; } public void setlast_name(String last_name){ this.last_name=last_name; } public void setemail_add(String email_add){ this.email_add=email_add; } public void settelephone(String telephone){ this.telephone=telephone; } @Override public String toString(){ return "Customer details"+ " First name of the customer :" + this.first_name+","+ "Last name of the customer:" + this.last_name+","+ "Home addres of the customer: "+ this.home_add+","+ "Email address of the customer: "+this.email_add+ ","+ "The customer telephone contact: "+ this.telephone; } }
public abstract class Account{ ArrayList <Transaction_Account> transacct = new ArrayList <>(); String acctnum; double bal; String first_name; String last_name; String home_add; String email_add; String telephone; public Account(String first_name, String last_name, String acctnum, double bal){ this.first_name = first_name; this.last_name = last_name; this.acctnum = acctnum; this.bal = bal; } //setters and getters methods //getters methods public String getfirst_name(){ return first_name; } public String getlast_name(){ return last_name; } public String gethome_add(){ return home_add; } public String getemail_add(){ return email_add; } public String getacctnum(){ return acctnum; } public double getbal(){ return bal; } public void setfirst_name(String first_name){ this.first_name = first_name; } //setters method public void setlast_name(String last_name){ this.last_name = last_name; } public void sethome_add(String home_add){ this.home_add = home_add; } public void setemail_add(String email_add){ this.email_add = email_add; } public void setacctnum(String acctnum){ this.acctnum= acctnum; } public void setbal(double bal){ this.bal=bal; } //end of getters and setters methods //start of the withdraw methods public void withdraw(double total_amt){ if(total_amt < bal){ System.out.print("Your transaction declined, insufficient funds: $"+ bal); } else{ System.out.println("\n "+ "Your current balance is"+this.bal); Transaction_Account newtrans = new Transaction_Account(new Date(), 'W', this.bal, 0,0, "Withdrawal made"); } //end of the withdraw method } //start of the deposit method public void deposit(double total_amt){ this.bal +=total_amt; System.out.print("\n"+total_amt+"Your balance is:"+this.bal); Transaction_Account newtrans = new Transaction_Account(new Date(), 'D', bal,0,0, "Deposit deposited"); } //end of the deposit method //toString method @Override public String toString(){ return "Customers details" + this.first_name+" "+this.last_name+" "+this.acctnum+" "+ this.home_add+" "+" "+this.email_add +" "+this.bal; } }
public class Transaction_Account{ private Date date; private double bal; private String description; private char type; private double total_amt; double newbal; private char W, D; public Transaction_Account(Date date, char type, double bal, double total_amt,double newbal, String description){ this.date = new Date(); this.type = type; this.bal=bal; this.total_amt = total_amt; this.newbal= newbal; this.description=description; } public Date getDate(){ return date; } public char gettype(){ return type; } public double getbal(){ return bal; } public String getdescription(){ return description; } public double gettotal_amt(){ return total_amt; } public double getnewbal(){ double newbal = bal - total_amt; setbal(bal); return newbal; } public void setDate(Date date){ this.date=date; } public void settype(char type){ this.type=type; } public void setbal(double bal){ this.bal=bal; } public void setdescription(String description){ this.description=description; } public void settotal_amt(double total_amt){ this.total_amt = total_amt; } public void setnewbal(double newbal){ this.newbal = newbal; } @Override public String toString(){ return "\n"+new Date()+" "+ "Type "+ this.type + " "+ "Account Balance"+ this.bal +" "+"Description"+ this.description; } }
public class Saving_Account extends Account{ private float interestRate; public Saving_Account(String first_name, String last_name, String acctnum, double bal, float interestRate){ super(first_name, last_name, acctnum, bal); this.interestRate=interestRate; } public float getinterestRate(){ return interestRate; } public double getbal(){ return bal; } public void setinterestRate(float interestRate){ this.interestRate = interestRate/100; } public void setbal(double bal){ this.bal=bal; } public void payInterest(){ double total_amt= getbal(); double bal=0; bal=(total_amt + (total_amt *getinterestRate())); setbal(bal); System.out.println("Account balance with interest is: $"+bal); Transaction_Account newtrans = new Transaction_Account(new Date(), 'I', bal,0,0,"Interest Paid"); } //withdrawal method @Override public void withdraw(double total_amt){ double bal=0; double acctamt=0; if(acctamt < total_amt){ System.out.println("Insufficient funds, balance is :$"+ acctamt); } else{ bal = acctamt -= total_amt; setbal(bal); System.out.println(); } } @Override public void deposit(double total_amt){ double acctamt = getbal(); bal = acctamt+=total_amt; setbal(bal); System.out.println("Your deposit amount is: $"+ bal + "was successful, your new balance is: $"+bal); Transaction_Account newtrans= new Transaction_Account(new Date(), 'D', bal, 0,0, "deposit made"); } @Override public String toString(){ return this.toString()+ "Interest Rate"+ interestRate; } }
public Chequing_Account(String first_name, String last_name, String acctnum, double bal){ super(first_name, last_name, acctnum, bal); } public float getoverdraft(){ return overdraft; } public void setoverdraft(float overdraft){ if(bal < overdraft){ System.out.println("Sorry but the limit for the overdraft cannot exceeded : $"+ overdraft); } } public void withdrawal(double total_amt){ double acctamt=getbal(); double bal=0; if(total_amt > bal && total_amt < 0){ System.out.println("I'm sorry but you have gone over your limit"); } else{ bal = acctamt-=total_amt; setbal(bal); System.out.println(total_amt+"Your current balance is:$"+ bal); Transaction_Account newtrans= new Transaction_Account(new Date(), 'W', bal, 0,0, "Withdrawal made"); } } @Override public void deposit(double total_amt){ double acctamt = getbal(); double bal = 0; bal = acctamt+=total_amt; setbal(bal); System.out.println("You have deposited: $"+total_amt+ "have been added to your account balance"+ "Your new balance is: $"+total_amt); Transaction_Account newtrans = new Transaction_Account(new Date(), 'D', bal,0,0,"Deposit deposited"); } @Override public String toString(){ return this.toString()+ "Over Draft Limit"+ this.overdraft; } }
*/ public class BankAccount { public static void main(String[]args){ Scanner keyin = new Scanner(System.in); char type; boolean quit; boolean isContains; String first_name; String last_name; String acctnum; double bal=0; float interestRate; System.out.println("\n "+ "Please select one of the following opeitons"); System.out.println("| o-To Open Account |"); System.out.println("| d-To Make a deposit"); System.out.println("| w-To Make a Withdrawal"); System.out.println("| i-To Pay Interest"); System.out.println("| t-To View the Transation"); System.out.println("| q-To quit"); type = keyin.next().trim().toUpperCase().toLowerCase().charAt(0); while (type !='q'){ if(type == 'o'){ System.out.println("please select the type of account you will like to open s-Saving or c-Chequing"); type = keyin.next().trim().toUpperCase().toLowerCase().charAt(0); switch (type) { case 's': System.out.println("Enter the account holder first name"); first_name = keyin.next(); System.out.println("Please enter a saving account number"); acctnum = keyin.next(); System.out.println("Please enter a starting balance $"+bal); bal = keyin.nextDouble(); System.out.println("Please enter your current interest rate"); interestRate = keyin.nextFloat(); break; case 'c': System.out.println("Please enter a chequing account number:"); acctnum=keyin.next(); System.out.println("Enter a starting balance:"); bal=keyin.nextDouble(); break; case 'd': System.out.println("Please enter the account number you wish to make a deposit to"); acctnum = keyin.next(); break; default: break; } } } }
Please select one of the following opeitons | o-To Open Account | | d-To Make a deposit | w-To Make a Withdrawal | i-To Pay Interest | t-To View the Transation | q-To quit