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 TypeMethodDescriptionvoidbooleancheckLoanPayment(LocalDate today) booleanstatic Loanstatic LoangetBaseLoan(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.intstatic int[]getCollateralBracket(int rating) static intgetCollateralIncrement(int rating, boolean interestPositive) static int[]getInterestBracket(int rating) static intgetMaxYears(int rating) Determines the maximum number of years by clamping the given rating to a valid range.intgetRate()intintgetYears()inthashCode()booleanvoidpaidLoan()static intrecalculateCollateralFromInterest(int rating, int interest) static intrecalculateInterestFromCollateral(int rating, int collateral) voidsetCollateral(int collateral) voidsetFinancialTerm(FinancialTerm financialTerm) voidsetInstitution(String institution) voidsetNextPayment(LocalDate nextPayment) voidsetOverdue(boolean overdue) voidsetPaymentAmount(Money paymentAmount) voidsetPrincipal(Money principal) voidsetRate(int rate) voidsetReferenceNumber(String referenceNumber) voidsetRemainingPayments(int remainingPayments) voidsetYears(int years) toString()voidwriteToXML(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
Loanobject 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- Abooleanflag that indicates whether the Gray Monday event is active, which impacts loan terms significantly.date- The current in-game date as aLocalDateobject, used to determine if Gray Monday conditions apply.- Returns:
- A
Loanobject 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
ratingfalls 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()
-