feat(model): introduce transaction hierarchy with deposit, withdraw, and transfer types

This commit is contained in:
2026-06-05 19:20:24 +03:30
parent 281d47463e
commit 8cb8c11260
4 changed files with 143 additions and 27 deletions
@@ -0,0 +1,36 @@
package dev.banking.model;
/**
* Represents a deposit operation.
*/
public final class DepositTransaction extends Transaction {
private final int accountId;
public DepositTransaction(
int accountId,
int amount
) {
super(amount);
if (accountId < 0) {
throw new IllegalArgumentException(
"Invalid account id."
);
}
this.accountId = accountId;
}
public int getAccountId() {
return accountId;
}
@Override
public String toString() {
return "DepositTransaction{" +
"accountId=" + accountId +
", amount=" + getAmount() +
'}';
}
}