Add project files.

This commit is contained in:
2019-11-18 16:59:38 +01:00
parent 5ec0c4fa3e
commit eef116b5f6
22 changed files with 841 additions and 0 deletions

View File

@ -0,0 +1,35 @@
using System;
namespace BrokerageLib {
public class CommissionCalculator {
public decimal DetermineVariableRate(int unitsSold, decimal unitPrice) {
// Sales representative gets top commission rate
// if they sell over the sales threshold amount
// or if they sell more than the max unit threshold
if (unitsSold < 0)
{
throw new ArgumentOutOfRangeException("UnitsSold cannot be less than zero.");
}
if (unitPrice < 0)
{
throw new ArgumentOutOfRangeException("unitPrice cannot be less than zero.");
}
decimal grossSale = unitsSold * unitPrice;
if (grossSale > Constants.CommissionThreshold.SalesAmount || unitsSold > Constants.CommissionThreshold.UnitAmount)
{
return grossSale * Constants.CommissionRate.Top;
}
else
{
return grossSale * Constants.CommissionRate.Standard;
}
}
}
}