3.Create a class called Password that represents the password for a user account
ID: 3667532 • Letter: 3
Question
3.Create a class called Password that represents the password for a user account. The class should have at least one string data member representing the password and the following member functions:
A constructor that creates an empty password.
Get function that returns the current password.
Set function that changes the current password to a given string. This function should not change the password if the new string is less than 8 characters in length or if the new string is the same as the previously set password. A new data member may be required to implement this!
Explanation / Answer
private String pass;
public void setpass(String pass) throws Exception{
if(!(pass.equals("")||pass=="")){
this.pass = pass;
}
}
public String getpass(){
return this.pass;
}
public void setpass(string pass) throws Exception{
this.pass = string;
}
public int getpass(){
return this.pass;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.