Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. @Override
  2. public void changeDetails() throws Exception {
  3.  
  4. sendMessage(2); // send a tag number of a method before sending object
  5. int option;
  6. input = new Scanner(System.in); // user input stream, object will be dereferenced when method returns
  7.  
  8. do{
  9. System.out.println("Choose from these choices");
  10. System.out.println("-------------------------n");
  11. System.out.println("1 - Changed Name");
  12. System.out.println("2 - Change Surname");
  13. System.out.println("3 - Change Address");
  14. System.out.println("4 - Change Password");
  15. System.out.println("0 - Exit");
  16.  
  17. option = input.nextInt(); // takes input normally
  18. sendMessage(option); // tell server what peace of information to process
  19. switch(option){
  20. case 1: System.out.println("Enter new name: ");
  21. sendMessage(input.nextLine()); // but skips this input and expecting nextInt input from above again
  22. break;
  23. case 2: System.out.println("Enter new surname: ");
  24. sendMessage(input.nextLine());
  25. break;
  26. case 3: System.out.println("Enter new address: ");
  27. sendMessage(input.nextLine());
  28. break;
  29. case 4: System.out.println("Enter new password: "); // good practice to ask for old password and check // before allowing password to be changed
  30. sendMessage(input.nextLine());
  31. break;
  32. }
  33.  
  34. System.out.println(receiveMessage());// waiting for response from server
  35. }while(option != 0);
  36.  
  37. sendMessage(0); // tell server that editing is done
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement