Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a class called Person with the properties listed: int id, Sring iayame Suring middleame, String lastlame Soing email, Suring ssn, int age. The

image text in transcribed

1. Create a class called Person with the properties listed: int id, Sring iayame Suring middleame, String lastlame Soing email, Suring ssn, int age. The Person class shoud have getters and setters for all properties other than id. (You may use Eclipse to help you auto-generate these.) a. Person class should also have a getter for id b Create c. In addition to these getters and setters, Person should have the a no-arg constructor for Person following instance methods: String tRSt 0g0-returns full name, like-Edgar Allen Poe. String getEmaiDomain-retuns the domain portion of an email (after the as in "gmail.com String getLast4SSN!) - returns the last 4 digits of the Social Security Add validation checking methods estatic boolean validAgelString testAge) a. You wW have to convert the tastAge String to an int to store it after validation static booleanvalidEmajString testEmail) estatic boolean validsSNString testSSH) for the age, email and Youmay have done this via the setters in the past However, this time, let's make them class-level (static) methods to validate these fields as best you can. Give some thought to what advantages this approach would have. 2. Notes on validation. Here is a list of validation checks you should perform. Soe are easier to implement than others, and there are many ways to correctly validate these aspects of the fields. Implement as many of these checks as you can. "You may accept any value for the names Extra Credit: Is there a good way to validate a name? Do a litte research on topic and include your answer. If there is, include y our algorthm. Age entered by user The String entered must be an integer greater than 18 * If the String is greater than 100 you should log an info message Email address string entered by user String must contanand at least one String must only contain one ength * Amust follow the The domain name (the part aebut before the firstt e at least one character in b. be applicable Iwwgive out extra credit for especially ciever email validation tests. Make sure to document and comment your ideas Cleanly there are far more resfrictions on emai addresses than those isted above. See i you can think of any others that might Social Security Number string entered by user String must contain two- characters in the correct position The length of the SSN must be 11 total characters String must contain only digits or numbers d. 3. b. If you encounter invalid data for any of these fields. log it using the logging API of Java. (Do not use SygeAAu RARI 00 Static variables: Keep track of the highest age entered for a Person in a static variable. Create a driver program ersopSpp to test the class Prompt user for all Person properties except id. You can hardcode any id you like, but use the id as the HashMap key Accept any value for the name field Only accapt valid values for age, email and 5A Create a Person with the valid input Create subclasses for Instructor and Student Instructors should hae a Deartment Students should have a Major Generate getters and setters b. C. 5. Add the Person, the Student and the Instructor to a HashMap In the Driver, create a Student & an Instructor (Hardcoded, do not prompt for Input Add each of these three instances (the hardcoded Student & Instructor, and previously created Person) to a HashMap using the id as the key 6. Perform the following after creating each person in the Driver: Loop through the HashMap and display "The person's full name and what kind of Person are they The person's email domain The last 4 digits of the person's Social Security N umber Whether the person S is the oldest in the collection The major for the Student, the department for the Instructor

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions

Question

How to Determine the Appropriate Number of Degrees of Freedom

Answered: 1 week ago