Commit 497942c
Changed files (7)
src/domain/Capacity.cs
@@ -0,0 +1,56 @@
+namespace domain
+{
+ using System.Collections.Generic;
+
+ 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 new Quantity(0, new BOED());
+ //return this
+ //.increases
+ //.Where(x => x.IsBeforeOrOn(month))
+ //.Sum(x => x.IncreasedCapacity());
+ return null;
+ }
+
+ 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;
+ }
+ }
+ }
+}
src/domain/domain.csproj
@@ -43,6 +43,7 @@
<Compile Include="Greeting.cs" />
<Compile Include="BOED.cs" />
<Compile Include="Clock.cs" />
+ <Compile Include="Capacity.cs" />
<Compile Include="Commodity.cs" />
<Compile Include="CommoditySplits.cs" />
<Compile Include="DeclineCurve.cs" />
@@ -50,11 +51,13 @@
<Compile Include="EstimatedNetProductionFor.cs" />
<Compile Include="GasPlant.cs" />
<Compile Include="Month.cs" />
+ <Compile Include="Months.cs" />
<Compile Include="Oppurtunity.cs" />
<Compile Include="Percent.cs" />
<Compile Include="Production.cs" />
<Compile Include="Quantity.cs" />
<Compile Include="Range.cs" />
+ <Compile Include="Summation.cs" />
<Compile Include="TypeCurve.cs" />
<Compile Include="Units.cs" />
<Compile Include="Well.cs" />
src/domain/DrillSchedule.cs
@@ -16,22 +16,12 @@ namespace domain
public IQuantity EstimatedGrossProductionFor<Commodity>(Month month) where Commodity : ICommodity, new()
{
- IQuantity result = new Quantity(0, new BOED());
- Accept(well =>
- {
- result = result.Plus(well.GrossProductionFor<Commodity>(month));
- });
- return result;
+ return wells.Select(well => well.GrossProductionFor<Commodity>(month)).Sum();
}
public IQuantity EstimatedNetProductionFor<Commodity>(Month month) where Commodity : ICommodity, new()
{
- IQuantity result = new Quantity(0, new BOED());
- Accept(well =>
- {
- result = result.Plus(well.NetProductionFor<Commodity>(month));
- });
- return result;
+ return wells.Select(well => well.NetProductionFor<Commodity>(month)).Sum();
}
public void Accept(IVisitor<IWell> visitor )
src/domain/GasPlant.cs
@@ -36,92 +36,20 @@ namespace domain
var results = new List<Month>();
months.Accept(month =>
{
- if(IsOverCapacity(month)){
+ if(IsOverCapacity(month))
results.Add(month);
- }
});
return results;
}
bool IsOverCapacity(Month month)
{
- var production = TotalProductionFor(month);
- if( capacity.AvailableFor(month).IsGreaterThan(production) ){
- return true;
- }
- return false;
+ return capacity.AvailableFor(month).IsGreaterThan(TotalProductionFor(month));
}
- IQuantity TotalProductionFor(Month month)
- {
- IQuantity result = new Quantity(0, new BOED());
- wells.Each(x =>
- {
- result = result.Plus( x.GrossProductionFor<Gas>(month));
- });
- return result;
- }
- }
-
- 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 new Quantity(0, new BOED());
- //return this
- //.increases
- //.Where(x => x.IsBeforeOrOn(month))
- //.Sum(x => x.IncreasedCapacity());
- return null;
- }
-
- 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;
- }
- }
- }
- public static class Summation
- {
- static public IQuantity Sum(this IEnumerable<IQuantity> items)
+ IQuantity TotalProductionFor(Month month)
{
- var result = 0m.BOED();
- foreach (var item in items) {
- result = result.Plus(item);
- }
- return result;
+ return wells.Select(well => well.GrossProductionFor<Gas>(month)).Sum();
}
}
}
src/domain/Month.cs
@@ -70,12 +70,4 @@ namespace domain
return string.Format("{0} {1}", date.Year, date.Month);
}
}
-
- public static class Months
- {
- public static Month January(this int year)
- {
- return new Month(year,01);
- }
- }
}
src/domain/Months.cs
@@ -0,0 +1,54 @@
+namespace domain
+{
+ public static class Months
+ {
+ public static Month January(this int year)
+ {
+ return new Month(year,01);
+ }
+ public static Month February(this int year)
+ {
+ return new Month(year,2);
+ }
+ public static Month March(this int year)
+ {
+ return new Month(year,3);
+ }
+ public static Month April(this int year)
+ {
+ return new Month(year,04);
+ }
+ public static Month May(this int year)
+ {
+ return new Month(year,05);
+ }
+ public static Month June(this int year)
+ {
+ return new Month(year,06);
+ }
+ public static Month July(this int year)
+ {
+ return new Month(year,07);
+ }
+ public static Month August(this int year)
+ {
+ return new Month(year,08);
+ }
+ public static Month September(this int year)
+ {
+ return new Month(year,09);
+ }
+ public static Month October(this int year)
+ {
+ return new Month(year,10);
+ }
+ public static Month November(this int year)
+ {
+ return new Month(year,11);
+ }
+ public static Month December(this int year)
+ {
+ return new Month(year,12);
+ }
+ }
+}
src/domain/Summation.cs
@@ -0,0 +1,16 @@
+namespace domain
+{
+ using System.Collections.Generic;
+
+ public static class Summation
+ {
+ static public IQuantity Sum(this IEnumerable<IQuantity> items)
+ {
+ var result = 0m.BOED();
+ foreach (var item in items) {
+ result = result.Plus(item);
+ }
+ return result;
+ }
+ }
+}