//Works on the accountNum phase public void accountNum(string buttonID) { //If they press enter if (buttonID == "Enter") { //If length isn't 6 then shout at them if (inputted.Length != 6) { changePhase("AccountNum"); myATMScreen.setError("Please only input a 6 digit code"); return; } //check account int tempInt; tempInt = myBank.findAccount(Convert.ToInt32(inputted)); //If account doesn't exist then shout at them if (tempInt == -1) { changePhase("AccountNum"); myATMScreen.setError("Please enter a valid account number"); return; } account = myBank.getAccount(tempInt); changePhase("Pin"); } else if (buttonID == "Clear") { changePhase("AccountNum"); } else if (buttonID != "Cancel" && buttonID.Length == 1) { myATMScreen.setInput(myATMScreen.getInput() + buttonID); inputted += buttonID; } }
//Changes the phase public void changePhase(string tempPhase) { phase = tempPhase; inputted = ""; myATMScreen.blankOut(); switch (phase) { case "AccountNum": myATMScreen.setMain("Please enter your account number:"); break; case "Pin": myATMScreen.setMain("Please enter your pin:"); break; case "Options": myATMScreen.setMain("What would you like to do?"); myATMScreen.setSide("Check Balance", 0); myATMScreen.setSide("Withdraw Cash", 1); myATMScreen.setSide("Exit", 2); break; case "Balance": myATMScreen.setMain("Your current balance is £" + account.getBalance()); myATMScreen.setError("Please press Cancel to return to the menu"); break; case "Withdraw": myATMScreen.setMain("How much would you like to withdraw?"); myATMScreen.setSide("£10", 0); myATMScreen.setSide("£20", 1); myATMScreen.setSide("£50", 2); myATMScreen.setSide("£100", 3); myATMScreen.setSide("Other", 5); myATMScreen.setError("You can also press cancel to return to the menu"); break; case "readNumber": myATMScreen.setMain("Enter how much you would like to withdraw."); myATMScreen.setError("You can also press cancel to return to the menu"); myATMScreen.setInput(Convert.ToString(balanceInput)); break; } }