/// <summary>
        /// Returns a ComparatorResult object for the two provided systems or null if the comparison cannot be completed.
        /// </summary>
        /// <param name="systemEstimate"></param>
        /// <param name="systemReport"></param>
        /// <returns></returns>
        public ComparatorResult CompareBySystem(SystemEstimate systemEstimate, SystemReport systemReport)
        {
            //Return object
            ComparatorResult comparatorResult = new ComparatorResult();

            //If the system object names don't match, abort.
            if (systemEstimate.Name != systemReport.Name)
            {
                throw new SystemNameMismatchException();
            }
            try
            {
                comparatorResult.SystemName           = systemEstimate.Name;
                comparatorResult.IsWorkCompleted      = IsSystemComplete(systemEstimate, systemReport);
                comparatorResult.EstimatePhaseCodes   = GetEstimatedPhaseCodes(systemEstimate);
                comparatorResult.FinishedPhaseCodes   = GetFinishedPhaseCodes(systemReport);
                comparatorResult.UnfinishedPhaseCodes = GetUnfinishedPhaseCodes(systemEstimate, systemReport);
                comparatorResult.PercentComplete      = GetPercentComplete(systemEstimate, systemReport);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
            return(comparatorResult);
        }
 /// <summary>
 /// Returns a rounded double that represents the percentage of phase codes that have been completed.
 /// </summary>
 /// <param name="systemEstimate"></param>
 /// <param name="systemReport"></param>
 /// <returns></returns>
 private double GetPercentComplete(SystemEstimate systemEstimate, SystemReport systemReport)
 {
     //Check if the
     if (systemEstimate.GetPhaseCodeCount() > 0)
     {
         double percentComplete = ((double)systemReport.GetPhaseCodeCount()) / ((double)systemEstimate.GetPhaseCodeCount());
         return(Math.Round((double)percentComplete, 2));
     }
     else
     {
         throw new Exception("There are either no phase codes on record for the system: " + systemEstimate.Name + " or else the estimate failed to populate.");
     }
 }
        /// <summary>
        /// Returns true if all the phase codes associated with the system have been reported as complete.
        /// </summary>
        /// <param name="systemEstimate"></param>
        /// <param name="systemReport"></param>
        /// <returns></returns>
        private bool IsSystemComplete(SystemEstimate systemEstimate, SystemReport systemReport)
        {
            bool completeness = false;

            if (GetPercentComplete(systemEstimate, systemReport) == 1.0)
            {
                completeness = true;
                return(completeness);
            }
            else
            {
                return(completeness);
            }
        }
        /// <summary>
        /// Returns a list of PhaseCode objects for phase codes that have not been reported as complete.
        /// </summary>
        /// <param name="systemEstimate"></param>
        /// <param name="systemReport"></param>
        /// <returns></returns>
        private List <PhaseCode> GetUnfinishedPhaseCodes(SystemEstimate systemEstimate, SystemReport systemReport)
        {
            List <string> reportedFullPhaseCodes = systemReport.GetFullPhaseCodeStrings();

            //Obtain the difference.
            List <PhaseCode> unfinishedPhaseCodes = new List <PhaseCode>();

            foreach (PhaseCode p in systemEstimate.PhaseCodes)
            {
                if (!reportedFullPhaseCodes.Contains(p.FullPhaseCode))
                {
                    unfinishedPhaseCodes.Add(p);
                }
            }
            return(unfinishedPhaseCodes);
        }
 /// <summary>
 /// Returns a list of PhaseCode objects for phase codes that have been reported as complete.
 /// </summary>
 /// <param name="systemReport"></param>
 /// <returns></returns>
 private List <PhaseCode> GetFinishedPhaseCodes(SystemReport systemReport)
 {
     //Return the list of reported phase codes.
     return(systemReport.PhaseCodes);
 }