Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can you please help me write the following methods for class LockableAccount the

ID: 3880610 • Letter: C

Question

can you please help me write the following methods for class LockableAccount
the fields are:
private static int ACCOUNT_NUM_MAX;
private static int ACCOUNT_NUM_MIN;
private int accountNumber;
private String emailAddress;
private boolean locked;
private String notification;
private String password;
private String username;

1) addNotification
public void addNotification(java.lang.String notificationIn)

Sets the notification of the account.

Parameters:getEmailAddresspublic java.lang.String getEmailAddress()

Returns the account's email address; the String returned depends on the locked state of the account. If the account is not locked it will return the emailAddress as it is stored. If the account is locked the String will be the first character of the emailAddress with the remainder of the characters in the emailAdress as asterisks *.

Returns: The full or partially hidden email address of the account

2)getAccountNumberString
public java.lang.String getAccountNumberString()

Returns the account number; the String returned depends on the locked state of the account and if the account number is valid. If the account number is invalid returns the String "Invalid account number, please contact customer support" whether or not the account is unlocked. If the account number is valid and the account is unlocked it will return the account number as a String; if the account is locked it will return asterisks in place of the digits.

Returns: The full or partially hidden account number

3)getNotificationpublic java.lang.String 
getNotification()

Returns the notification; the String returned depends on the locked state of the account and if there is a notification. If there is no notification returns the String "No notification". If there is a notification and the account is unlocked it will return the notification. If there is a notification and the account is locked it will return the String "You have a notification".

Returns: The notification string

Explanation / Answer

All three methods are the members of class LockableAccount:

public String addNotification(String notification){

this.notification = notification;

if(locked){

return emailAddress;

}

else{

String str = emailAddress.charAt(0);

for(int i=1;i<emailAddress.length();i++){

str = str + "*";

}

return str;

}

}

public String getAccountNumberString(){

if(accountNumber < ACCOUNT_NUM_MIN || accountNumber > ACCOUNT_NUM_MAX){

return "Invalid account number, please contact customer support.";

}

int accntNum = accountNumber;

String accNum = "";

if(locked){

while(accntNum>0){

accNum = accNum + "*";

accntNum = accntNum/10;

}

}

else{

while(accntNum>0){

accNum = (accntNum%10) + accNum;

accntNum = accntNum/10;

}

}

return accNum;

}

public String getNotification(){

if(notification.length() == 0){

return "No Notification";

}

if(locked){

return "You have a notification";

}

else{

return notification;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote