Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void changeDetails() throws Exception {
- sendMessage(2); // send a tag number of a method before sending object
- int option;
- input = new Scanner(System.in); // user input stream, object will be dereferenced when method returns
- do{
- System.out.println("Choose from these choices");
- System.out.println("-------------------------n");
- System.out.println("1 - Changed Name");
- System.out.println("2 - Change Surname");
- System.out.println("3 - Change Address");
- System.out.println("4 - Change Password");
- System.out.println("0 - Exit");
- option = input.nextInt(); // takes input normally
- sendMessage(option); // tell server what peace of information to process
- switch(option){
- case 1: System.out.println("Enter new name: ");
- sendMessage(input.nextLine()); // but skips this input and expecting nextInt input from above again
- break;
- case 2: System.out.println("Enter new surname: ");
- sendMessage(input.nextLine());
- break;
- case 3: System.out.println("Enter new address: ");
- sendMessage(input.nextLine());
- break;
- case 4: System.out.println("Enter new password: "); // good practice to ask for old password and check // before allowing password to be changed
- sendMessage(input.nextLine());
- break;
- }
- System.out.println(receiveMessage());// waiting for response from server
- }while(option != 0);
- sendMessage(0); // tell server that editing is done
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement