summaryrefslogtreecommitdiff
path: root/lib/currency.cs
blob: 02ad0412fb60d3688bbb77f42848f1af430f7d72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class Currency : UnitOfMeasure
{
  public static Currency CAD = new Currency("CAD");
  public static Currency USD = new Currency("USD");
  public static Currency MXN = new Currency("MXN");

  string pneumonic;

  public Currency(string pneumonic)
  {
    this.pneumonic = pneumonic;
  }

  public decimal convert(decimal amount, UnitOfMeasure currency)
  {
    if (currency == Currency.USD) {
      return amount * 2;
    }

    if (currency == Currency.MXN) {
      return amount / 10;
    }

    return amount;
  }

  public override string ToString()
  {
    return this.pneumonic;
  }
}