Skip to content

Commit

Permalink
Feat: Updated validation for Transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyah committed May 25, 2026
1 parent 1c015f8 commit ada261d
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.ntnu.idi.idatt2003.g40.mappe.model;

import edu.ntnu.idi.idatt2003.g40.mappe.service.TransactionCalculator;
import edu.ntnu.idi.idatt2003.g40.mappe.utils.Validator;

/**
* Transaction abstract class.
Expand Down Expand Up @@ -40,14 +41,22 @@ public abstract class Transaction {

protected Transaction(final Share share, final int week,
final TransactionCalculator calculator)
throws IllegalArgumentException{
if (share == null || calculator == null) {
throw new IllegalArgumentException("Invalid stock or calculator!");
} else {
this.share = share;
this.week = week;
this.calculator = calculator;
throws IllegalArgumentException {
if (share == null
|| calculator == null) {
throw new IllegalArgumentException(
"Invalid configuration for transaction!"
);
}
if (!Validator.VALID_WEEK.isValid(Integer.toString(week))) {
throw new IllegalArgumentException(
Validator.VALID_WEEK.getErrorMessage()
);
}
this.share = share;
this.week = week;
this.calculator = calculator;

}

/**
Expand Down

0 comments on commit ada261d

Please sign in to comment.