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); }
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); }
public bool BlockCommandLimit(int counter) { if (counter < countCommandLimit) { return(false); } else { DataInputOutputManager.OutputMessenger("So much command!"); return(true); } }
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); } }
//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); } }
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); } }
public bool BlockTimeLimitSassion(bool i) { if (i) { blockStateTimer = false; timerSession.Start(); } timerSession.Elapsed += TimerSassionElapsed; if (blockSassionTimer) { DataInputOutputManager.OutputMessenger("Time session is out!"); } return(blockSassionTimer); }
//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); }
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); } }
public MainMenu(Card card) { Run(); CheckPinCode(card); if (!card.BlockCard && !BlockMenu) { DataInputOutputManager.OutputMessenger("MENU"); } else { while (card.BlockCard && BlockMenu) { DataInputOutputManager.InputMessenger(); } } }
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(); }
public void Run() { blocker.BlockTimeLimitSassion(true); blocker.BlockTimeLimitState(true); DataInputOutputManager.OutputMessenger("INSERT"); }
public void Exit(Card card) { DataInputOutputManager.OutputMessager("BYE ", card.IDUser); }