From 8dc4088f8e68d6698bb5cbdb5c74703397a59c34 Mon Sep 17 00:00:00 2001 From: mo k Date: Thu, 26 Apr 2012 12:47:14 -0600 Subject: collapse nested if into single if. --- src/domain/Month.cs | 1 + 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, IIncrementable { 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(Month month) where Commodity : ICommodity, new(); + IQuantity NetProductionFor(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(Month month) where Commodity : ICommodity, new(); - IQuantity NetProductionFor(Month month) where Commodity : ICommodity, new(); - void FlowInto(IFacility facility); - } } -- cgit v1.2.3