Exemplo n.º 1
0
        public static void RunScan(FileInputScanner inputScanner, IPassportValidator passportValidator)
        {
            var passports = inputScanner.Scan();

            var validatedPassports =
                passports
                .Select(p => (passport: p, isValid: passportValidator.IsPassportValid(p)))
                .ToArray();

            Console.WriteLine($"Valid passports: {validatedPassports.Count(p => p.isValid)}");
            Console.WriteLine($"Invalid passports: {validatedPassports.Count(p => !p.isValid)}");
        }
Exemplo n.º 2
0
        internal static int Main()
        {
            var fileInputScannerTask1          = new FileInputScanner("input.txt");
            var injectedPassportValidatorTask1 = new InjectedPassportValidator();

            RunScan(fileInputScannerTask1, injectedPassportValidatorTask1);
            Console.WriteLine();

            var fileInputScannerTask2          = new FileInputScanner("input.txt");
            var injectedPassportValidatorTask2 = new InjectedImprovedPassportValidator();

            RunScan(fileInputScannerTask2, injectedPassportValidatorTask2);
            Console.ReadLine();

            return(0);
        }