mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
26 lines
565 B
C#
26 lines
565 B
C#
namespace DuplicateMagic;
|
|
|
|
public class DiscountService
|
|
{
|
|
public decimal ApplyDiscount(decimal price, string tier)
|
|
{
|
|
return tier switch
|
|
{
|
|
"Gold" => price * 0.90m,
|
|
"Silver" => price * 0.95m,
|
|
"Bronze" => price * 0.98m,
|
|
_ => price
|
|
};
|
|
}
|
|
|
|
public decimal CalculateShipping(int weight, int ratePerUnit, int zones)
|
|
{
|
|
return weight * ratePerUnit * zones;
|
|
}
|
|
|
|
public decimal ApplyTax(decimal price, decimal taxRate)
|
|
{
|
|
return price * (1 + taxRate);
|
|
}
|
|
}
|