Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.*;
- import java.io.*;
- public class ATMProtocol {
- private static final int MAINMENU = 0;
- private static final int ENTERUSERNAME = 1;
- private static final int ENTERPASSWORD = 2;
- private static final int SELCTIONMENU = 3;
- private static String greetingMessage = "Hi and welcome to the 1337-bank, pleae log in";
- private int state = MAINMENU;
- private int currentJoke = 0;
- private String[] selections = { "Turnip", "Little Old Lady", "Atch", "Who", "Who" };
- private String[] messages = { greetingMessage,
- "Please enter your user name",
- "Couldn't find any user with that name, please try again",
- "Please enter your password",
- "Login successfull",
- "Incorrect password, please try again",
- "Welcome to Bank! (1)Balance, (2)Withdrawal, (3)Deposit, (4)Exit"};
- public String processInput(String theInput) {
- String theOutput = null;
- if (state == MAINMENU) {
- theOutput = messages[0];
- state = ENTERUSERNAME;
- } else if (state == ENTERUSERNAME) {
- if (validateUserName(theInput)) {
- theOutput = messages[4];
- state = ENTERPASSWORD;
- } else {
- theOutput = messages[3];
- }
- } else if (state == ENTERPASSWORD) {
- if (validatePassword(theInput)) {
- theOutput = messages[5];
- state = SELCTIONMENU;
- } else {
- theOutput = messages[6];
- state = ENTERPASSWORD;
- }
- } else if (state == SELCTIONMENU) {
- theOutput = messages[7];
- }
- return theOutput;
- }
- }
Add Comment
Please, Sign In to add comment