コード例 #1
0
        private void ParseOneAccountEntry(string[] lines)
        {
            int x = 0;
            int y = 0;

            int[] response = new int[(lines[1].Length / 3)];
            //manage emtpy string
            int index = 0;

            foreach (string line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    lines[index] = "                           ";
                }
                index++;
            }

            //start parsing
            for (; x < 27; x += 3)
            {
                string[] letter = new String[]
                {
                    lines[y].Substring(x, 3),
                    lines[y + 1].Substring(x, 3),
                    lines[y + 2].Substring(x, 3),
                };
                var aChar = new CharModel(letter);
                int digit = letterToNum(aChar);
                AccountNumChars[(x / 3)] = aChar;
                AccountNum[(x / 3)]      = digit;
            }
        }
コード例 #2
0
 public AccountNumModel(string[] linesOfPrints)
 {
     AccountNumChars = new CharModel[9];
     AccountNum      = new int[9];
     ParseOneAccountEntry(linesOfPrints);
     Status = ValidateAccountNumber(AccountNum);
 }
コード例 #3
0
        private int letterToNum(CharModel a)
        {
            int result = 10;

            if (a == _zero)
            {
                result = 0;
            }
            if (a == _one)
            {
                result = 1;
            }
            if (a == _two)
            {
                result = 2;
            }
            if (a == _three)
            {
                result = 3;
            }
            if (a == _four)
            {
                result = 4;
            }
            if (a == _five)
            {
                result = 5;
            }
            if (a == _six)
            {
                result = 6;
            }
            if (a == _seven)
            {
                result = 7;
            }
            if (a == _eight)
            {
                result = 8;
            }
            if (a == _nine)
            {
                result = 9;
            }
            return(result);
        }
コード例 #4
0
 public AccountNumModel(int[] numbers)
 {
     AccountNumChars = new CharModel[9];
     AccountNum      = new int[9];
     Status          = ValidateAccountNumber(AccountNum);
 }