Class Loan
-
Constructor Summary
ConstructorsConstructorDescriptionLoan
(int principal, int rate, int years, FinancialTerm financialTerm, int collateral, LocalDate today) Loan
(String institution, String referenceNumber, Money principal, int rate, int years, FinancialTerm financialTerm, int collateral, LocalDate today) Loan
(Money principal, int rate, int years, FinancialTerm financialTerm, int collateral, LocalDate today) -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
checkLoanPayment
(LocalDate today) boolean
static Loan
static Loan
getBaseLoan
(int rating, boolean simulateGrayMonday, LocalDate date) Computes and returns a base loan object based on the player's rating, the current date, and campaign-specific conditions such as the Gray Monday event.int
static int[]
getCollateralBracket
(int rating) static int
getCollateralIncrement
(int rating, boolean interestPositive) static int[]
getInterestBracket
(int rating) static int
getMaxYears
(int rating) Determines the maximum number of years by clamping the given rating to a valid range.int
getRate()
int
int
getYears()
int
hashCode()
boolean
void
paidLoan()
static int
recalculateCollateralFromInterest
(int rating, int interest) static int
recalculateInterestFromCollateral
(int rating, int collateral) void
setCollateral
(int collateral) void
setFinancialTerm
(FinancialTerm financialTerm) void
setInstitution
(String institution) void
setNextPayment
(LocalDate nextPayment) void
setOverdue
(boolean overdue) void
setPaymentAmount
(Money paymentAmount) void
setPrincipal
(Money principal) void
setRate
(int rate) void
setReferenceNumber
(String referenceNumber) void
setRemainingPayments
(int remainingPayments) void
setYears
(int years) toString()
void
writeToXML
(PrintWriter pw, int indent)
-
Constructor Details
-
Loan
public Loan(int principal, int rate, int years, FinancialTerm financialTerm, int collateral, LocalDate today) -
Loan
public Loan(Money principal, int rate, int years, FinancialTerm financialTerm, int collateral, LocalDate today) -
Loan
public Loan(String institution, String referenceNumber, Money principal, int rate, int years, FinancialTerm financialTerm, int collateral, LocalDate today)
-
-
Method Details
-
getInstitution
-
setInstitution
-
getReferenceNumber
-
setReferenceNumber
-
getPrincipal
-
setPrincipal
-
getRate
public int getRate() -
setRate
public void setRate(int rate) -
getYears
public int getYears() -
setYears
public void setYears(int years) -
getFinancialTerm
-
setFinancialTerm
-
getCollateral
public int getCollateral() -
setCollateral
public void setCollateral(int collateral) -
getRemainingPayments
public int getRemainingPayments() -
setRemainingPayments
public void setRemainingPayments(int remainingPayments) -
getPaymentAmount
-
setPaymentAmount
-
getNextPayment
-
setNextPayment
-
isOverdue
public boolean isOverdue() -
setOverdue
public void setOverdue(boolean overdue) -
determineCollateralAmount
-
determineRemainingValue
-
calculateAmortization
public void calculateAmortization() -
paidLoan
public void paidLoan() -
checkLoanPayment
-
getBaseLoan
Computes and returns a base loan object based on the player's rating, the current date, and campaign-specific conditions such as the Gray Monday event.This method determines the loan terms that the player is eligible for based on their performance rating and whether the game is simulating the Gray Monday event. If the Gray Monday event is active, a special predatory loan with significantly higher interest rates and penalties is offered. Otherwise, the loan terms are progressively better as the player's rating improves.
The returned
Loan
object contains all relevant terms such as the principal, interest rate, repayment duration, financial term, and associated penalty.- Parameters:
rating
- The player's performance rating as an integer. Defaults to higher loan penalties and stricter terms for lower ratings.simulateGrayMonday
- Aboolean
flag that indicates whether the Gray Monday event is active, which impacts loan terms significantly.date
- The current in-game date as aLocalDate
object, used to determine if Gray Monday conditions apply.- Returns:
- A
Loan
object representing the player's base loan terms based on their rating and event conditions.
-
getInterestBracket
public static int[] getInterestBracket(int rating) -
getCollateralBracket
public static int[] getCollateralBracket(int rating) -
getMaxYears
public static int getMaxYears(int rating) Determines the maximum number of years by clamping the given rating to a valid range.This method returns a value that ensures the input
rating
falls within the specified range of 1 to 7. Ratings below 1 are clamped to 1, and ratings above 7 are clamped to 7. The clamped value is directly returned.The clamped values coincide with the Experience Level ordinals (Ultra-Green, Green, etc). This means a Veteran-rated campaign (ordinal 4) could take up to a 4-year loan.
- Parameters:
rating
- the input rating value to be clamped.- Returns:
- the clamped rating, guaranteed to be a value between 1 and 7 (inclusive).
-
getCollateralIncrement
public static int getCollateralIncrement(int rating, boolean interestPositive) -
recalculateCollateralFromInterest
public static int recalculateCollateralFromInterest(int rating, int interest) -
recalculateInterestFromCollateral
public static int recalculateInterestFromCollateral(int rating, int collateral) -
writeToXML
-
generateInstanceFromXML
-
toString
-
equals
-
hashCode
public int hashCode()
-