48 lines
1.0 KiB
Java
48 lines
1.0 KiB
Java
package dev.banking.model;
|
|
|
|
public class BankAccount {
|
|
|
|
private final int accountId;
|
|
private long balance;
|
|
|
|
public BankAccount(int accountId, long initialBalance) {
|
|
this.accountId = accountId;
|
|
this.balance = initialBalance;
|
|
}
|
|
|
|
public int getAccountId() {
|
|
return accountId;
|
|
}
|
|
|
|
/*
|
|
* TODO
|
|
* Implement a thread-safe balance reader.
|
|
*/
|
|
public long getBalance() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
/*
|
|
* TODO
|
|
* Implement a thread-safe deposit operation.
|
|
*/
|
|
public void deposit(int amount) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
/*
|
|
* TODO
|
|
* Implement a thread-safe withdrawal operation.
|
|
*/
|
|
public void withdraw(int amount) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
/*
|
|
* TODO
|
|
* Implement an atomic and deadlock-free transfer.
|
|
*/
|
|
public void transfer(BankAccount target, int amount) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
} |