Assignment 3 due Thursday, January 31 at 11:59pm on Canvas Pair Programming Extra Credit Opportunity (1 pt)
User Profiles (10 pts)
names.txt input file: Jiming Wu F 4082123458 jwu@gmail.com abc123 James Brown M 8315678432 jaime.boy.brown@hotmail.com jjjbbb123 Leanna Perez F 4087654433 leaperez@yahoo.com letmein Xing Li M 8313214555 xing.li@sbcglobal.net 555!!!hi Stacey Cahill O 8312123333 scahill@gmail.com r0tr@tr^n Mohammed Abbas M 4083134444 downtown_abbas@yahoo.com 1@m@bb@s Kumari Chakrabarti F 4086667777 kukuchakrabarti@hotmail.com passw0rd Shakil Smith M 4082123333 shakattaq@gmail.com qwerty Jung Ahrin F 8319257788 jung_ahrin@yahoo.com password1 Pedro Martinez M 4086162323 pedro2018@sbcglobal.net 123456789 Ally Gu O 4089256776 i_am_ally@comcast.net trustno1 Tamara White F 8317778978 tamtastic@gmail.com 1qaz2wsx Alvin Ngo M 4089256677 drngo@hotmail.com qwertyuiop Abir Fadel M 8316645325 greatabs@comcast.com qazwsx Brad Feinman M 8312023443 bradisrad@gmail.com 11111 Xiaohang Yue M 8318990033 yue95@yahoo.com adobe123 User.java Starter Code: /** * Definition of the User class * @author * CIS 36B * Assignment 3 */ 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 * "<variable> unknown" * e.g. "name unknown" */public User() {} /** * 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) {} /** * 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 ""; } /** * Returns a phone number formatted * in the style (XXX) XXX-XXXX * @return the formatted phone number */ public String getFormattedPhone() { return ""; } /** * Returns the user email * @return the user email */ public String getEmail() { return ""; } /** * 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) { return; } /** * Assigns a phone number to the phone field * @param user_phone the phone number to assign */ public void setPhone(String 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) { 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 ""; } }Profile.java Starter Code: /** * Profile.java * @author * CIS 36B * Assignment 6.1 */ import java.util.ArrayList; import java.util.Scanner; import java.io.File; import java.io.IOException; import java.io.PrintWriter; public class Profile { public static void main(String[] args) throws IOException { ArrayList<User> users = new ArrayList<User>(); File names = new File("names.txt"); Scanner input = new Scanner(names); String name, phone, gender, email, password; while (input.hasNextLine()) { //read in the information for each user //create a new User object //call setter methods to assign values to user object //insert user object into users ArrayList } input.close(); input = new Scanner(System.in); System.out.println("Welcome!\n"); System.out.print("Enter your email address: "); email = input.nextLine(); System.out.print("Enter your password: "); password = input.nextLine(); //search } /** * 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 linearSearch(String email, String password, ArrayList<User> users) { return -1; } }Notes and Helpful Hints:
Name: Leanna Perez Gender: F Phone: (408) 876-5443 Email: leaperez@yahoo.com
Sample Output: Welcome! Enter your email address: leaperez@yahoo.com Enter your password: letmein Hi, Leanna Perez! We have the following information on file for you: Name: Leanna Perez Gender: F Phone: (408) 876-5443 Email: leaperez@yahoo.com Alternately: Enter your email address: jaylaw@sbcglobal.net Enter your password: 555111jjjlll Sorry! We don't have your account on file. Let's create an account for you! Enter your name: Jennifer Lawrence Enter your gender: F Enter your 10 digit phone number (no spaces or punctuation): 5555555555 Thank you, Jennifer Lawrence! Your account has now been created. Name: Jennifer Lawrence Gender: F Phone: (555) 555-5555 Email: jaylaw@sbcglobal.net What to submit:
|