feat(model): introduce transaction hierarchy with deposit, withdraw, and transfer types
This commit is contained in:
@@ -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() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user