summaryrefslogtreecommitdiff
path: root/src/domain/Production.cs
blob: e780e8fbf3af7d862892d8669bc1a39c518c9d89 (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
namespace domain
{
  public class Production
  {
    Month month;
    IQuantity produced;
    IComposition split;

    public Production(Month month, IQuantity produced, IComposition split)
    {
      this.month = month;
      this.produced = produced;
      this.split = split;
    }

    public bool IsFor(Month otherMonth)
    {
      return month.Equals(otherMonth);
    }

    public virtual bool OccursDuring(IRange<Month> period)
    {
      return period.Contains(this.month);
    }

    public virtual bool IsGreaterThanAvailableAt(IFacility facility)
    {
      return produced.IsGreaterThan(facility.AvailableCapacityFor(this.month));
    }

    public IQuantity ProductionOf<T>() where T : ICommodity, new()
    {
      return split.PercentageOf<T>(produced);
    }
  }
}