This site requires JavaScript, please enable it in your browser!
Greenfoot back
divinity
divinity wrote ...

2017/6/27

SavingAccount is not abstract and does not override abstract method withdraw(double) in Accounts ----

divinity divinity

2017/6/27

#
hi danpost I am doing a program where I am to do a banking that imitates a bank. it have three classes and a gui. the program states that it should launch a gui that allows the user to perform three actions 1. enter personal and account information for new customers 2perform basic operation deposit and withdraw on acct which exist in the bank database and 3 print the contents of the database to the console the classes are an Account class, SavingAccount class and a CheckingAccounts class both the SavingAccount and CheckingAccount class is giving this errors:(SavingAccount is not abstract and does not override abstract method withdraw(double in Accounts----) The rules states that the account class is abstract but not the savings account and checking account class. the account class should have an abstract method called deposit and withdraw. my question is: how do i fix the error without implements all abstract class or making both the SavingAccounts class and CheckingAccount class abstract. how do i get rid of the error. here is the codes for all three class: please note. I have not finish with it as yet.
this is the account class:

package Banking;


public abstract class Accounts {
    
    private int customer_ID;
    private double balance;
    
    public Accounts(int customer_ID, double balance){
        this.balance = balance;
        this.customer_ID = customer_ID;
    }
    public int getcustomer_ID(){
        return customer_ID;
    }
    public double getbalance(){
        return balance;
    }
    public void setcustomer_ID(int customer_ID){
        this.customer_ID = customer_ID;
    }
    public void setbalance(double balance){
        this.balance = balance;
    }
        public abstract boolean deposit(double amount);
        public abstract boolean withdraw(double amount);
        
    @Override
      public String toString(){
          String returndetails = "Customer ID"+ customer_ID + "Balance "+balance;
          

this is the savingaccount class
package Banking;


public class SavingAccount extends Accounts {
    
    private double amt, newbal;
    private double interest_rate = 500;
    
    public SavingAccount(int customer_ID, double balance){
        super(customer_ID, balance);
        
        
     }
    public double getinterest_rate(){
        return interest_rate;
    }
    public void setinterest_rate(double interest_rate){
        this.interest_rate = interest_rate;
    }
    
    
    public void payinterest(){
        
        if(amt > interest_rate){
           newbal = newbal* interest_rate;
        }
    }
    
}

this is the checkingaccount class
package Banking;


public class CheckingAccount extends Accounts {
    
    private double overdraft;
    
    public CheckingAccount(int customer_ID, double balance){
        super(customer_ID, balance);
    }
    public double getoverdraft(){
        return overdraft;
    }
    public void setoverdraft(double overdraft){
        this.overdraft = overdraft;
    }
    @Override
    public String toString(){
        
        String returndetails = "Overdraft Limit "+ overdraft;
        
        return returndetails;
    }
}
danpost danpost

2017/6/28

#
You just need to add the two methods:
public boolean deposit(double amount)
// and
public boolean withdrawal(double amount)
into the two subclasses (SavingAccount and CheckingAccount) with their appropriate codes (as per lines 27 and 28 of the Account class).
You need to login to post a reply.