Created
September 24, 2014 04:23
-
-
Save javaeeeee/daf3de69fea80d53bdfc to your computer and use it in GitHub Desktop.
BankAccount class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BankAccount { | |
private String ownerName; | |
private double balance; | |
private boolean isEnoughMoney(double amount) { | |
return balance > amount; | |
} | |
public void deposit(double amount) { | |
balance += amount; | |
} | |
public void withdraw(double amount) { | |
if (isEnoughMoney(amount)) { | |
balance -= amount; | |
} else { | |
//Report an error; | |
System.out.println("Not Enough Money"); | |
} | |
} | |
public double getBalance() { | |
return balance; | |
} | |
//Getters and Setters for ownerName omitted for brevity | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment