Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
Created September 24, 2014 04:23
Show Gist options
  • Save javaeeeee/daf3de69fea80d53bdfc to your computer and use it in GitHub Desktop.
Save javaeeeee/daf3de69fea80d53bdfc to your computer and use it in GitHub Desktop.
BankAccount class
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