Guest User

Untitled

a guest
Jul 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1.  
  2. import java.net.*;
  3. import java.io.*;
  4.  
  5. public class ATMProtocol {
  6. private static final int MAINMENU = 0;
  7. private static final int ENTERUSERNAME = 1;
  8. private static final int ENTERPASSWORD = 2;
  9. private static final int SELCTIONMENU = 3;
  10. private static String greetingMessage = "Hi and welcome to the 1337-bank, pleae log in";
  11.  
  12. private int state = MAINMENU;
  13. private int currentJoke = 0;
  14.  
  15. private String[] selections = { "Turnip", "Little Old Lady", "Atch", "Who", "Who" };
  16. private String[] messages = { greetingMessage,
  17. "Please enter your user name",
  18. "Couldn't find any user with that name, please try again",
  19. "Please enter your password",
  20. "Login successfull",
  21. "Incorrect password, please try again",
  22. "Welcome to Bank! (1)Balance, (2)Withdrawal, (3)Deposit, (4)Exit"};
  23.  
  24. public String processInput(String theInput) {
  25. String theOutput = null;
  26.  
  27. if (state == MAINMENU) {
  28. theOutput = messages[0];
  29. state = ENTERUSERNAME;
  30. } else if (state == ENTERUSERNAME) {
  31. if (validateUserName(theInput)) {
  32. theOutput = messages[4];
  33. state = ENTERPASSWORD;
  34. } else {
  35. theOutput = messages[3];
  36. }
  37. } else if (state == ENTERPASSWORD) {
  38. if (validatePassword(theInput)) {
  39. theOutput = messages[5];
  40. state = SELCTIONMENU;
  41. } else {
  42. theOutput = messages[6];
  43. state = ENTERPASSWORD;
  44. }
  45. } else if (state == SELCTIONMENU) {
  46. theOutput = messages[7];
  47. }
  48. return theOutput;
  49. }
  50. }
Add Comment
Please, Sign In to add comment