diff options
| author | mo k <mo@mokhan.ca> | 2012-04-26 12:47:14 -0600 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-04-26 12:47:14 -0600 |
| commit | 8dc4088f8e68d6698bb5cbdb5c74703397a59c34 (patch) | |
| tree | 847262a2ae3afe619aa112c939147533cc0e2d58 | |
| parent | 5999f7dfdd6d2a27becc4612c9f8800ac674fbda (diff) | |
collapse nested if into single if.
| -rw-r--r-- | src/domain/Month.cs | 1 | ||||
| -rw-r--r-- | src/domain/Well.cs | 20 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/domain/Month.cs b/src/domain/Month.cs index 6bc9359..92b82f3 100644 --- a/src/domain/Month.cs +++ b/src/domain/Month.cs @@ -5,6 +5,7 @@ namespace domain public class Month : IComparable<Month>, IIncrementable<Month> { DateTime date; + public static readonly Month Infinity = new Month(2099, 12); public Month(int year, int month) { diff --git a/src/domain/Well.cs b/src/domain/Well.cs index e6019f3..cdb1043 100644 --- a/src/domain/Well.cs +++ b/src/domain/Well.cs @@ -5,6 +5,13 @@ namespace domain using System.Linq; using utility; + 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); + } + public class Well : IWell { Month initialProductionMonth; @@ -39,13 +46,11 @@ namespace domain void ensure_that_this_well_does_not_overflow_the_plant(IFacility facility) { - var period = initialProductionMonth.UpTo(new Month(2099, 12)); + var period = initialProductionMonth.UpTo(Month.Infinity); this.curve.Accept( production => { - if( production.OccursDuring(period)){ - if(production.IsGreaterThanAvailableAt(facility)) + if( production.OccursDuring(period) && production.IsGreaterThanAvailableAt(facility)) throw new Exception(); - } }); } @@ -54,11 +59,4 @@ namespace domain 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); - } } |
