diff --git a/snippet/ch4/Account.java b/snippet/ch4/Account.java new file mode 100644 index 0000000000000000000000000000000000000000..f1a0f6f8a4acd66673095b138dd477c5ca1310c4 --- /dev/null +++ b/snippet/ch4/Account.java @@ -0,0 +1,21 @@ +public class Account { + + private final String owner; + private double balance; + + public Account(String owner, double balance) { + this.owner = owner; + this.balance = balance; + } + + public Account(String owner) { + this(owner, 0.0); + } + + public String getOwner() { return this.owner; } + public double getBalance() { return this.balance; } + + public void deposite(double amount) { this.balance += amount; } + public void withdraw(double amount) { this.deposite(-amount); } + +}