summaryrefslogtreecommitdiff
path: root/src/domain/Well.cs
blob: 835e8b2fcb7aa3b8d50776a39a1251948cab9365 (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
namespace domain
{
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using utility;

  public class Well : IWell
  {
    Month initialProductionMonth;
    Percent workingInterest;
    TypeCurve curve;
    IFacility facility;

    public Well(Month initialProductionMonth, Percent workingInterest, TypeCurve curve)
    {
      this.initialProductionMonth = initialProductionMonth;
      this.workingInterest = workingInterest;
      this.curve = curve;
    }

    public IQuantity GrossProductionFor<Commodity>(Month month) where Commodity : ICommodity, new()
    {
      return curve.ProductionFor<Commodity>(month);
    }

    public IQuantity NetProductionFor<Commodity>(Month month) where Commodity : ICommodity, new()
    {
      return workingInterest.Reduce(GrossProductionFor<Commodity>(month));
    }

    public void FlowInto(IFacility facility)
    {
      ensure_that_this_well_is_not_already_flowing_into_a_plant();
      this.facility = facility;
      facility.AcceptFlowFrom(this);
    }

    void ensure_that_this_well_is_not_already_flowing_into_a_plant()
    {
      if(null != this.facility) throw new Exception();
    }
  }

  public interface IWell
  {
    IQuantity GrossProductionFor<Commodity>(Month month) where Commodity : ICommodity, new();
    IQuantity NetProductionFor<Commodity>(Month month) where Commodity : ICommodity, new();
    void FlowInto(IFacility facility);
  }
}