Develop #1

Open
HadiSharifi wants to merge 3 commits from develop into main
Showing only changes of commit dd2de9aef0 - Show all commits
@@ -35,6 +35,7 @@ public class BankAccount {
public void deposit(long amount) {
lock.writeLock().lock();
try {
if (amount < 0) throw new IllegalArgumentException("Amount cannot be negative");
balance += amount;
}
finally {
@@ -45,6 +46,8 @@ public class BankAccount {
public void withdraw(long amount) {
lock.writeLock().lock();
try {
if (amount < 0) throw new IllegalArgumentException("Amount cannot be negative");
if (balance < amount) throw new IllegalArgumentException("insufficient balance");
balance -= amount;
}
finally {
@@ -61,6 +64,8 @@ public class BankAccount {
try {
second.lock.writeLock().lock();
try {
if (amount < 0) throw new IllegalArgumentException("Amount cannot be negative");
if (amount > balance) throw new IllegalArgumentException("insufficient balance");
this.balance -= amount;
target.balance += amount;
} finally {