This repository has been archived on 2024-01-25. You can view files and clone it, but cannot push or open issues or pull requests.
Lab15_OOP/src/bank/BankAccount.java
2022-05-04 08:29:46 +02:00

28 lines
612 B
Java

package bank;
public abstract class BankAccount {
protected double balance;
protected String owner;
public double getBalance() {
return balance;
}
public void deposit(double amount){
balance += amount;
}
public boolean withdraw(double amount){
if(balance<amount){
System.out.println("Problem : cannot withdraw that amount");
return false;
}
balance -= amount;
return true;
}
@Override
public String toString() {
return owner + " have " + balance + "CHF on his account.";
}
}