Exemplo n.º 1
0
        public string GetCode(string[] input, KeypadType keypadType)
        {
            StringBuilder outputBuffer = new StringBuilder();

            if (keypadType == KeypadType.Exercise01)
            {
                ResetA();
            }
            else
            {
                ResetB();
            }

            for (int i = 0; i < input.Length; i++)
            {
                if (keypadType == KeypadType.Exercise01)
                {
                    outputBuffer.Append(GetDigitA(input[i]));
                }
                else
                {
                    outputBuffer.Append(GetDigitB(input[i]));
                }
            }

            return(outputBuffer.ToString());
        }
Exemplo n.º 2
0
    public BathroomSecurity(string input, KeypadType keypadType = KeypadType.Part1Keypad)
    {
        switch (keypadType)
        {
        case KeypadType.Part1Keypad:
            _keypad          = Keypad1;
            _currentPosition = new Position(1, 1);
            break;

        case KeypadType.Part2Keypad:
            _keypad          = Keypad2;
            _currentPosition = new Position(2, 0);
            break;

        default:
            throw new ArgumentException("Unsupported keypad type", "keypadType");
        }

        _keypadDimension = _keypad[0].Length;
        _input           = input;
    }