Skip to content

Instantly share code, notes, and snippets.

@Vaysman
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vaysman/9d04c244e15457945e30 to your computer and use it in GitHub Desktop.
Save Vaysman/9d04c244e15457945e30 to your computer and use it in GitHub Desktop.
package com.luxoft.bankapp.model;
// this is an incomplete class. use it as example.
public abstract class AbstractAccount {
protected float balance;
public AbstractAccount() {
balance = 0.0f;
}
// balance must be greater than or equal to 0
public AbstractAccount(float balance) {
if (balance < 0) {
throw new IllegalArgumentException("Initial balance must be greater than or equal to 0");
}
this.balance = balance;
}
public float getBalance() {
return balance;
}
public void deposit(float amount) {
if (amount <= 0) {
throw new IllegalArgumentException("Amount must be greater than 0");
}
balance += amount;
}
// other methods
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment