Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BankAccount {
- private int ID;
- private double balance;
- public BankAccount(int ID, double balance) {
- this.setID(ID);
- this.setBalance(balance);
- }
- public int getID() {
- return ID;
- }
- public void setID(int ID) {
- this.ID = ID;
- }
- public double getBalance() {
- return balance;
- }
- public void setBalance(double balance) {
- if(balance > 0){
- this.balance = balance;
- }
- }
- public void Deposit(double amount){
- this.balance += amount;
- }
- public void Withdraw(double amount){
- if(this.balance >= amount){
- this.balance -= amount;
- }else {
- System.out.println("No money");
- }
- }
- @Override
- public String toString() {
- return "[Account: " + this.ID + ", balance: " + this.balance + "]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement