Question
In C# Please! - Adjust the Withdrawl method to include an optional parameter, called IsOutOfNetwork. This should be boolean, and have a default value of
In C# Please!
- Adjust the Withdrawl method to include an optional parameter, called IsOutOfNetwork. This should be boolean, and have a default value of false. If your customer is making a withdrawl that is out of network (meaning they used an ATM not operated by the app's bank), tack on and addtional $2.50 to be deducted from their balance.
- Create a PayMortgage method that takes a Customer object as a parameter and returns a modified customer object back. Use the MortgagePrincipal and MortgageInterest properties to calculate how much money is dedeucted from the MortgagePrincipal after a payment. BE SURE IT CAN HANDLE EDGE CASE SCENARIOS! Assign the MortgagePrincipal property the value of the resut, and then return the modified customer object. Formula: MortgagePrincipal = MortgagePrincipal - (MortgagePrincpal * intrest). Interest must be value between 0 and 1.
using Week3UnitTests.Data; using Week3UnitTests.Model;
namespace Week3UnitTests { public class UnitOfWork : IUnitOfWork { List
public UnitOfWork(List
public void Deposit(int customerId, decimal amount) { if (amount <= 0) throw new Exception("Amount value must be greater than zero");
Customer? customer = _customers.FirstOrDefault(x => x.Id == customerId);
if (customer is null) throw new Exception($"No customer with ID of {customerId}"); int custIdx = _customers.IndexOf(customer);
_customers[custIdx].CurrentBalance += amount; }
public void Withdrawal(int customerId, decimal amount) { if (amount >= 0) throw new Exception("Amount value must be greater than zero");
Customer? customer = _customers.FirstOrDefault(x => x.Id == customerId);
if (customer is null) throw new Exception($"No customer with ID of {customerId}");
int custIdx = _customers.IndexOf(customer);
_customers[custIdx].CurrentBalance += amount; }
public decimal GetBalance(int customerId) { Customer? customer = _customers.FirstOrDefault(x => x.Id == customerId);
if (customer is null) throw new Exception($"Could not locate customer with ID of {customerId}");
return customer.CurrentBalance; }
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started