#Username and Password
1 messages Β· Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
I uploaded your attachments as gist. That way, they are easier to read for everyone, especially mobile users π
I uploaded your attachments as gist. That way, they are easier to read for everyone, especially mobile users π
Main
public class UsernameAndPassword {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
ArrayList<credentials> credlist = new ArrayList<credentials>();
System.out.print("Username: ");
String username = input.nextLine();
System.out.print("Password: ");
String password = input.nextLine();
credlist.add(new credentials(username, password));
System.out.println("Do you wish to change password? y/n");
String result = input.nextLine();
if (result.equals("y")){
// Change password and add new password
System.out.println("New password");
String newpassword = input.nextLine();
// Old Account
System.out.println("Old account");
System.out.println("Username: " + credlist.get(0).getusername());
System.out.println("Password: " + credlist.get(0).getpassword());
credlist.get(0).Updatepassword(newpassword);
// Updated Account
System.out.println("Updated account");
System.out.println("Username: " + credlist.get(0).getusername());
System.out.println("Password: " + credlist.get(0).getpassword());
} else {
System.out.println("Thank you");
}
}
}
Object
public class credentials {
public String username;
private String password;
public String result;
public credentials(String username,String password){
this.username = username;
this.password = password;
}
public String getusername(){
return this.username;
}
public String getpassword(){
return this.password;
}
public void Updatepassword(String newpassword){
this.password = newpassword;
}
public String returnafterUpdatepassword(String manufacturer){
return this.password;
}
}
I can't figure out what to do with returnafterUpdatepassword
but that's how you can update the value using object methods ^^
Detected code, here are some useful tools:
public class credentials {
public String username;
private String password;
public String result;
public credentials(String username, String password) {
this .username = username;
this .password = password;
}
public String getusername() {
return this .username;
}
public String getpassword() {
return this .password;
}
public void Updatepassword(String newpassword) {
this .password = newpassword;
}
public String returnafterUpdatepassword(String manufacturer) {
return this .password;
}
}
T^T thank you so much I can finally review it I can't be grateful enough β€οΈ
Hey, please avoid writing all of it. The idea is to guide em to the solution, not feed emπ
The code is not mine, the code I put is his/her, I just showed him/her how to do it, I just added something for him/her to review if I just tell him/her what to do without showing anything, everything will definitely be confusing ^^ and it also just ends up writing my own code for him/her
but don't worry, I'm not giving away my own code ^^ @bitter iris
unless they pay meπ€£
I actually learned from references and was able to figure out some errors