blob: 4cfd1d0b20631998f55e27eb7da9d053f76a1ee5 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
namespace domain
{
using System.Linq;
using System.Collections.Generic;
using domain;
using utility;
public class Capacity
{
IList<Increase> increases;
public Capacity(IQuantity initialCapacity):this(initialCapacity, Month.Now())
{
}
public Capacity(IQuantity initialCapacity, Month month)
{
this.increases = new List<Increase>();
this.IncreaseCapacity(initialCapacity, month);
}
public void IncreaseCapacity(IQuantity quantity, Month month)
{
this.increases.Add(new Increase(quantity, month));
}
public IQuantity AvailableFor(Month month)
{
return this.increases.Where(x => x.IsBeforeOrOn(month)).Select(x => x.IncreasedCapacity()).Sum<MCF>();
}
class Increase
{
IQuantity quantity;
Month month;
public Increase(IQuantity quantity, Month month)
{
this.quantity = quantity;
this.month = month;
}
public bool IsBeforeOrOn(Month other)
{
return month.IsBefore(other) || month.Equals(other);
}
public IQuantity IncreasedCapacity()
{
return this.quantity;
}
}
}
}
|