Question: INTRO JAVA I need help filling in these two methods. /** * Searches for a user whose email and password match * those currently stored

INTRO JAVA I need help filling in these two methods. /**

* Searches for a user whose email and password match

* those currently stored in the users ArrayList

* @param email the email that was input

* @param password the password input

* @param users the ArrayList storing customers on file

* @return the location of the user or -1 if not found

*/

public static int binarySearch(String email, String password, ArrayList users) {

}

/**

* Sorts an ArrayList of User objects alphabetically

* according to email address, using the bubbleSort

* algorithm

* @param users the ArrayList of Users

*/

public static void bubbleSort(ArrayList users){

}

} Here is the User class:

public class User {

private String name;

private String gender;

private String phone;

private String email;

private String password;

/**

* Default constructor - assigns

* all member variables to the value

* " unknown"

* e.g. "name unknown"

*/

public User() {

name = "name unknown";

gender = "gender unknown";

phone = "phone unknown";

email = "email unknown";

password = "password unknown";

}

/**

* Constructor for the User class

* @param theName the User name

* @param theGender the User gender

* @param thePhone the User phone

* @param theEmail the User email

* @param thePassword the User password

*/

public User(String theName, String theGender, String thePhone, String theEmail, String thePassword) {

name = theName;

gender = theGender;

phone = thePhone;

email = theEmail;

password = thePassword;

}

/**

* Returns the first and last name

* @return the user name

*/

public String getName() {

return name;

}

/**

* Returns the gender (F, M, or O)

* @return the gender

*/

public String getGender() {

return gender;

}

/**

* Returns a phone number formatted

* in the style (XXX)XXX-XXXX

* @return the formatted phone number

*/

public String getFormattedPhone() {

String num1 = phone.substring(0,4);

String num2 = phone.substring(4,7);

String num3 = phone.substring(7,11);

String formatPhone = "(" + num1 + ")" + num2 + "-" + num3;

return formatPhone;

}

/**

* Returns the user email

* @return the user email

*/

public String getEmail() {

return email;

}

/**

* Verifies that password equals the

* password on file for the user

* @param userInput the password entered

* @return whether the password entered matches

* the password stored

*/

public boolean verifyPassword(String userInput) {

return userInput.equals(password);

}

/**

* Assigns the user a first and last name

* @param user_name the name of the user

*/

public void setName(String user_name) {

name = user_name;

}

/**

* Assigns a value to the gender field

* @param user_gender a gender F, M or O

*/

public void setGender(String user_gender) {

gender = user_gender;

return;

}

/**

* Assigns a phone number to the phone field

* @param user_phone the phone number to assign

*/

public void setPhone(String user_phone) {

phone = user_phone;

return;

}

/**

* Assigns an email address to the email field

* @param user_email the email address to assign

*/

public void setEmail(String user_email) {

email = user_email;

return;

}

/**

* Assigns a password to the password field

* @param user_password the password to assign

*/

public void setPassword(String user_password) {

password = user_password;

}

/**

* Returns the formatted User info as a String

*/

@Override public String toString() {

return "Name: " + name

+ "Gender: " + gender

+ "Phone: " + phone

+ "Email: " + email;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!