Last active
August 29, 2015 14:12
-
-
Save Vaysman/9d04c244e15457945e30 to your computer and use it in GitHub Desktop.
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
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