Language in Java
We want you to implement a java class that will show details on users and throw exceptions where needed. The following requirements specify what fields you are expected to implement in your User class: – A private String firstName that specifies the first name of the user . A private String lastName that specifies the last name of the user – A private int age that specifies user’s age – A private String userID that specifies the user ID used for login – A private String phoneNum that specifies the user’s phone number (10-digit) Your User class will provide the following constructors; A no-arg constructor that creates a user with name=”” age=21, userID=”” and phoneNum=”” • A constructor that creates a user with specified name, age, userID and phoneNum o In the constructor, throw an exception if the age of the user is below 0 and above 99. O Also, throw an exception for invalid user ID (described below). O Also, throw an exception if the phoneNum length > 10. Your class will also provide the following methods: . Getters and Setters for all the fields (Make sure to throw appropriate exceptions as described above for the setters) A boolean method called is ValidUser ID which takes the userID and returns True or False. The userID is valid if it consists of at least 8 characters and contains at least one number. Throw an exception otherwise. If False, the method also prints a warning “Invalid User ID” = (Note: Your – LUI ILLOU LISU PEILS LLLL LLLL LL ID O L. 1 OL setter for user ID should also call this method) A String method deconstructPhone which returns the areaCode and the rest of the phone number. Format: Area Code: … Phone Number: ……. A display method that outputs the user object as follows: Name: … Age: … UserID: … Phone Number:… Area Code: … Phone: … Next write a main method that tests the features of the User class by; Creating a user object userl (Use the no-arg constructor). Set the name to “Sarah Holt”, userID=”sarahholt26!” and phone number=”9548926728″. Display this object using the display method. Create another user object user2 with name=”Kevin James”, age=25, userID=”kjames2552″ and phone number=”8019023100″. Display this object using the display method. Create a user object user3 with name=”Dante Couto”, userID=”dantetezza” and phone number=”95000″. Display the users details using the display method. Show transcribed image text We want you to implement a java class that will show details on users and throw exceptions where needed. The following requirements specify what fields you are expected to implement in your User class: – A private String firstName that specifies the first name of the user . A private String lastName that specifies the last name of the user – A private int age that specifies user’s age – A private String userID that specifies the user ID used for login – A private String phoneNum that specifies the user’s phone number (10-digit) Your User class will provide the following constructors; A no-arg constructor that creates a user with name=”” age=21, userID=”” and phoneNum=”” • A constructor that creates a user with specified name, age, userID and phoneNum o In the constructor, throw an exception if the age of the user is below 0 and above 99. O Also, throw an exception for invalid user ID (described below). O Also, throw an exception if the phoneNum length > 10. Your class will also provide the following methods: . Getters and Setters for all the fields (Make sure to throw appropriate exceptions as described above for the setters) A boolean method called is ValidUser ID which takes the userID and returns True or False. The userID is valid if it consists of at least 8 characters and contains at least one number. Throw an exception otherwise. If False, the method also prints a warning “Invalid User ID” = (Note: Your
– LUI ILLOU LISU PEILS LLLL LLLL LL ID O L. 1 OL setter for user ID should also call this method) A String method deconstructPhone which returns the areaCode and the rest of the phone number. Format: Area Code: … Phone Number: ……. A display method that outputs the user object as follows: Name: … Age: … UserID: … Phone Number:… Area Code: … Phone: … Next write a main method that tests the features of the User class by; Creating a user object userl (Use the no-arg constructor). Set the name to “Sarah Holt”, userID=”sarahholt26!” and phone number=”9548926728″. Display this object using the display method. Create another user object user2 with name=”Kevin James”, age=25, userID=”kjames2552″ and phone number=”8019023100″. Display this object using the display method. Create a user object user3 with name=”Dante Couto”, userID=”dantetezza” and phone number=”95000″. Display the users details using the display method.
Expert Answer
Answer to We want you to implement a java class that will show details on users and throw exceptions where needed. The following r…