public static string CheckCommandSimbols(this string inputObject)
        {
            inputObject = DataInputOutputManager.InputMessenger();
            string command = string.Empty;
            int    number;

            foreach (UserCommand u in Enum.GetValues(typeof(UserCommand)))
            {
                if (u.ToString() == inputObject)
                {
                    command = u.ToString();
                }
                else if (Int32.TryParse(inputObject, out number) && (int)u == number)
                {
                    command = number.ToString();
                }
                else
                {
                    if (inputObject.Length >= Enum.GetNames(typeof(UserCommand)).Length)
                    {
                        break;
                    }
                }
            }
            return(command);
        }
示例#2
0
 public ManagerATM(object card)
 {
     StartATM(card);
     if (!cardInput)
     {
         DataInputOutputManager.OutputMessenger("Cant get card.");
     }
 }
        public static double CheckSumSimbols(this string inputObject)
        {
            inputObject = DataInputOutputManager.InputMessenger();
            double number;

            Double.TryParse(inputObject, out number);
            return(number);
        }
        public static int CheckPinCodeSimbols(this string inputObject)
        {
            inputObject = DataInputOutputManager.InputMessenger();
            int number;

            Int32.TryParse(inputObject, out number);
            return(number);
        }
示例#5
0
 public bool BlockCommandLimit(int counter)
 {
     if (counter < countCommandLimit)
     {
         return(false);
     }
     else
     {
         DataInputOutputManager.OutputMessenger("So much command!");
         return(true);
     }
 }
示例#6
0
 public bool BlockBadCommand(int counter)
 {
     if (counter < countBadCommand)
     {
         DataInputOutputManager.OutputMessager("Limit of bad attempts ", countBadCommand - counter);
         return(false);
     }
     else
     {
         DataInputOutputManager.OutputMessenger("Bad command. YOURS CARD WAS BLOCK!");
         return(true);
     }
 }
示例#7
0
 //Counters
 public bool BlockBadSum(int counter)
 {
     ++counterBadCommand;
     if (counter < counBadSum && !BlockBadCommand(counterBadCommand))
     {
         DataInputOutputManager.OutputMessager("Wrong sum, you have attempts: ", counBadSum - counter);
         return(false);
     }
     else
     {
         DataInputOutputManager.OutputMessenger("So much bad sum. YOUR CARD WAS BLOCKED!");
         return(true);
     }
 }
示例#8
0
 public bool BlockCardPinCode(int counter)
 {
     if (counter < countBadPinCode)
     {
         ++counterBadCommand;
         DataInputOutputManager.OutputMessager("Wrong pin code, you have attempts: ", countBadPinCode - counter);
         return(false);
     }
     else
     {
         DataInputOutputManager.OutputMessenger("Wrong pin code. YOUR CARD WAS BLOCKED!");
         return(true);
     }
 }
示例#9
0
 public bool BlockTimeLimitSassion(bool i)
 {
     if (i)
     {
         blockStateTimer = false;
         timerSession.Start();
     }
     timerSession.Elapsed += TimerSassionElapsed;
     if (blockSassionTimer)
     {
         DataInputOutputManager.OutputMessenger("Time session is out!");
     }
     return(blockSassionTimer);
 }
示例#10
0
 //Timers
 public bool BlockTimeLimitState(bool i)
 {
     if (i)
     {
         blockStateTimer = false;
         timerState.Stop();
         timerState.Start();
     }
     timerState.Elapsed += TimerStateElapsed;
     if (blockStateTimer)
     {
         DataInputOutputManager.OutputMessenger("Time state is out!");
     }
     return(blockStateTimer);
 }
示例#11
0
        public void Operations(Card card, ManagerATM managarATM)
        {
            while (!card.BlockCard && !BlockMenu)
            {
                ++countCommands;
                BlockMenu     = (blocker.BlockBadCommand(countBadCommands) || blocker.BlockTimeLimitState(true) || blocker.BlockTimeLimitSassion(false) || blocker.BlockCommandLimit(countCommands)) ? true : false;
                enterUserData = enterUserData.CheckCommandSimbols();
                Enum.TryParse(enterUserData, true, out userCommand);
                switch (userCommand)
                {
                case UserCommand.BALANCE:
                    DataInputOutputManager.OutputMessenger(GetBalance(card).ToString());
                    BlockMenu            = (blocker.BlockTimeLimitState(false) || blocker.BlockTimeLimitSassion(false) || blocker.BlockCommandLimit(countCommands)) ? true : false;
                    managarATM.cardInput = (BlockMenu || card.BlockCard) ? false : true;
                    break;

                case UserCommand.CASH:
                    GetCash(card, cash.CheckSumSimbols());
                    DataInputOutputManager.OutputMessenger(card.Balance.ToString());
                    BlockMenu            = (blocker.BlockTimeLimitState(false) || blocker.BlockTimeLimitSassion(false) || blocker.BlockCommandLimit(countCommands)) ? true : false;
                    managarATM.cardInput = (BlockMenu || card.BlockCard) ? false : true;
                    break;

                case UserCommand.EXIT:
                    Exit(card);
                    BlockMenu            = (blocker.BlockTimeLimitState(false) || blocker.BlockTimeLimitSassion(false) || blocker.BlockCommandLimit(countCommands)) ? true : false;
                    managarATM.cardInput = (BlockMenu || card.BlockCard) ? false : true;
                    break;

                default:
                    ++countBadCommands;
                    BlockMenu            = (blocker.BlockTimeLimitState(false) || blocker.BlockTimeLimitSassion(false) || blocker.BlockCommandLimit(countCommands)) ? true : false;
                    managarATM.cardInput = (BlockMenu || card.BlockCard) ? false : true;
                    break;
                }
            }
            while (!managarATM.cardInput)
            {
                DataInputOutputManager.OutputMessenger("Menu blocked");
                DataInputOutputManager.InputMessenger();
                managarATM.cardInput = true;
                blocker.BlockTimeLimitSassion(true);
                blocker.BlockTimeLimitState(true);
                card.BlockCard = false;
                BlockMenu      = false;
                managarATM.StartMainMenu(card);
            }
        }
示例#12
0
 public MainMenu(Card card)
 {
     Run();
     CheckPinCode(card);
     if (!card.BlockCard && !BlockMenu)
     {
         DataInputOutputManager.OutputMessenger("MENU");
     }
     else
     {
         while (card.BlockCard && BlockMenu)
         {
             DataInputOutputManager.InputMessenger();
         }
     }
 }
示例#13
0
        static void Main(string[] args)
        {
            Card card = new Card
            {
                Balance   = 1000,
                BlockCard = false,
                IDUser    = "******",
            };
            ManagerATM managerATM = new ManagerATM(card);
            MainMenu   mainMenu   = managerATM.StartMainMenu(card);

            while (!card.BlockCard && !mainMenu.BlockMenu)
            {
                mainMenu.Operations(card, managerATM);
            }
            DataInputOutputManager.InputMessenger();
        }
示例#14
0
 public void Run()
 {
     blocker.BlockTimeLimitSassion(true);
     blocker.BlockTimeLimitState(true);
     DataInputOutputManager.OutputMessenger("INSERT");
 }
示例#15
0
 public void Exit(Card card)
 {
     DataInputOutputManager.OutputMessager("BYE ", card.IDUser);
 }