コード例 #1
0
        private static void DisplayTownPlannerReport(TownPlanner townPlanner, IEnumerable <int> houseNumbers)
        {
            var isFileValid = townPlanner.DoesNumberingStartsFromOne(houseNumbers);

            Console.WriteLine("The file is {0}", isFileValid?"valid":"not valid");

            var totalHouses = townPlanner.GetTotalNumberOfHouse(houseNumbers);

            Console.WriteLine("Total houses in the given street are {0}", totalHouses);

            var totalHousesOnNorth = townPlanner.GetTheHousesOnNorthSide(houseNumbers).Count();

            Console.WriteLine("Total houses on the north side of the street are {0}", totalHousesOnNorth);

            var totalHousesOnSouth = townPlanner.GetTheHousesOnSouthSide(houseNumbers).Count();

            Console.WriteLine("Total houses on the south side of the street are {0}", totalHousesOnSouth);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var townPlanner  = new TownPlanner(new Util());
            var houseNumbers = townPlanner.GetHouseNumbers();

            // story 1
            Console.WriteLine("Story 1");
            DisplayTownPlannerReport(townPlanner, houseNumbers);

            // story 2:
            Console.WriteLine();
            Console.WriteLine("Story 2");

            //approach 1
            ShowTheSuggessionToThePaperBoyOnApprachOne(new PaperBoyHelper(townPlanner), houseNumbers);

            //approach 2
            ShowTheSuggessionToThePaperBoyOnApprachTwo(new PaperBoyHelper(townPlanner), houseNumbers);

            Console.ReadKey();
        }