-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSum.cs
More file actions
32 lines (27 loc) · 807 Bytes
/
Sum.cs
File metadata and controls
32 lines (27 loc) · 807 Bytes
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
32
using System;
namespace TDD_Money
{
public class Sum : Expression
{
public readonly Expression Augend;
public readonly Expression Addend;
public Sum(Expression augend, Expression addend)
{
Augend = augend;
Addend = addend;
}
public Money Reduce(Bank bank, String toCurrency)
{
int amount = Addend.Reduce(bank, toCurrency).Amount + Augend.Reduce(bank,toCurrency).Amount;
return new Money(amount, toCurrency);
}
public Expression Plus(Expression addend)
{
return new Sum(this, addend);
}
public Expression Times(int multiplier)
{
return new Sum(Augend. Times( multiplier), Addend.Times(multiplier));
}
}
}