/// <summary> /// Requests a loan to a foreign country. /// </summary> /// <param name="country">The country to whom the request is performed.</param> private void AskForLoan(LenderCountry country) { userInterface.DisplayLoanApplicationScreen(); LoanApplicationResult loanApplicationResult = engine.AskForLoan(country); userInterface.DisplayLoanApplicationResultScreen(loanApplicationResult); }
/// <summary> /// Asks for foreign aid in the form of a loan to either America or Russia. /// </summary> /// <param name="country">The country to which the loan request will be made.</param> /// <returns>The loan application result that includes if the loan has been approved or refused.</returns> public LoanApplicationResult AskForLoan(LenderCountry country) { LoanApplicationResult loanApplicationResult = new LoanApplicationResult { Country = country }; if (IsTooEarlyForLoan()) { loanApplicationResult.IsAccepted = false; loanApplicationResult.RefusalType = LoanApplicationRefusalType.TooEarly; return(loanApplicationResult); } if (HasLoanBeenGrantedPreviously(country)) { loanApplicationResult.IsAccepted = false; loanApplicationResult.RefusalType = LoanApplicationRefusalType.AlreadyUsed; return(loanApplicationResult); } GroupType groupType = groupService.GetGroupTypeByCountry(country); Group group = groupService.GetGroupByType(groupType); loanApplicationResult.GroupName = group.Name; if (group.Popularity <= governmentService.GetMonthlyMinimalPopularityAndStrength()) { loanApplicationResult.IsAccepted = false; loanApplicationResult.RefusalType = LoanApplicationRefusalType.NotPopularEnough; } else { loanApplicationResult.IsAccepted = true; loanApplicationResult.RefusalType = LoanApplicationRefusalType.None; loanApplicationResult.Amount = CalculateLoanAmount(group); accountService.ChangeTreasuryBalance(loanApplicationResult.Amount); } return(loanApplicationResult); }
public GroupType GetGroupTypeByCountry(LenderCountry country) { GroupType groupType; switch (country) { case LenderCountry.America: groupType = GroupType.Americans; break; case LenderCountry.Russia: groupType = GroupType.Russians; break; default: throw new InvalidEnumArgumentException(nameof(country), (int)country, country.GetType()); } return(groupType); }
/// <summary> /// Determines if a loan has already been requested and granted by the specified country. /// </summary> /// <param name="country">The country to which the loan request will be made.</param> /// <returns><c>true</c> if the loan has been granted before; otherwise, <c>false</c>.</returns> private bool HasLoanBeenGrantedPreviously(LenderCountry country) { // TODO: Check if loans have been used return(false); }
/// <summary> /// Asks for foreign aid in the form of a loan to either America or Russia. /// </summary> /// <param name="country">The country to which the loan request will be made.</param> /// <returns>The loan application result that includes if the loan has been approved or refused.</returns> public LoanApplicationResult AskForLoan(LenderCountry country) { return(loanService.AskForLoan(country)); }