示例#1
0
        public void Start()
        {
            _view.DrawTitle();

            var infoBits = ProcessInput();

            var controlBitsCount = _model.GetControlBitsCount(infoBits.Length);

            _view.ShowControlBitCount(controlBitsCount);

            var controlBitsIndexes = _model.GetControlBitsIndexes(controlBitsCount);
            var temporaryBitArray  = new byte[infoBits.Length + controlBitsCount];

            _model.InsertInfoBits(infoBits, controlBitsIndexes, ref temporaryBitArray);
            _view.ShowTemporaryArray(temporaryBitArray, controlBitsIndexes);

            var controlBits = _model.CalculateControlBits(temporaryBitArray, controlBitsCount, controlBitsIndexes);

            _model.InsertControlBits(controlBits.Item1, controlBitsIndexes, ref temporaryBitArray);
            _view.ShowControlBitsCalculation(controlBits.Item1, controlBits.Item2, temporaryBitArray);
            _view.ShowEncodedArray(temporaryBitArray, controlBitsIndexes);


            var mistakeIndex = ProcessMistakeInput(temporaryBitArray.Length);

            _model.MakeMistake(ref temporaryBitArray, mistakeIndex);
            _view.ShowArrayWithMistake(temporaryBitArray, mistakeIndex);

            controlBits = _model.CalculateControlBits(temporaryBitArray, controlBitsCount, controlBitsIndexes);
            _view.ShowCheckSumCalculation(controlBits.Item1, controlBits.Item2, temporaryBitArray);
            var mistakeNumber = Utils.BitArrayToInt(controlBits.Item1.Reverse().ToArray());

            _view.ShowMistakeNumber(mistakeNumber);
            _model.MakeMistake(ref temporaryBitArray, mistakeNumber - 1);
            _view.ShowMistakeFix(temporaryBitArray, mistakeIndex);
        }