コード例 #1
0
        static void Main(string[] args)
        {
            CustomsOfficer customsOfficer = new CustomsOfficer();
            List <string>  rawData        = Helper.ReadInDataAndSeparateWhenBlankLine("data.txt");

            foreach (string data in rawData)
            {
                List <CustomsForm> singleGroup = customsOfficer.CreateCustomsFormGroup(data);
                customsOfficer.PopulateGroupOfGroups(singleGroup);
            }
            List <string> answeredYes = new List <string>();

            foreach (List <CustomsForm> group in customsOfficer.groupOfGroups)
            {
                answeredYes.Add(customsOfficer.FindAllYesInAGroup(group));
            }
            int result = customsOfficer.HowManyYesInAllGroups(answeredYes);

            Console.WriteLine($"The sum of all unique Yes answers in all groups is {result}.");

            // Challenge 2

            result = 0;
            foreach (List <CustomsForm> group in customsOfficer.groupOfGroups)
            {
                result += customsOfficer.SecondTry(group);
            }
            Console.WriteLine($"The number of questions that everyone in a group answered Yes to is {result}.");
        }
コード例 #2
0
        public void CustomsOfficer_HowManyYesInAllGroups_WorksAsExpected()
        {
            List <CustomsForm> _testData    = _customsOfficer.CreateCustomsFormGroup("a bc cfh d");
            string             _refinedData = _customsOfficer.FindAllYesInAGroup(_testData);
            List <string>      _dataList    = new List <string>()
            {
                _refinedData
            };
            int result = _customsOfficer.HowManyYesInAllGroups(_dataList);

            Assert.That(result, Is.EqualTo(6));
        }