Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a class called Person with the following properties: x The Person class should have getters and setters for all properties other than id.

1. Create a class called Person with the following properties: x The Person class should have getters and setters for all properties other than id. (Use Eclipse to help you auto-generate these.) x Person class should also have a getter for id x In addition to these getters and setters, Person should have the following instance methods: x toString returns full name, like "Edgar Allen Poe" x getEmailDomain returns the domain portion of an email (after the @), as in "xyz.com" x getLast4SSN returns the last four digits of the Social Security Number x Add some validation to age, email and ssn. You may have done this via the setters in the past. However, this time, let's add class (static) methods to validate these fields as best you can. Give some thought to what advantages this approach would have.

2. Create a driver program PersonApp to test the class x Prompt user for all Person properties except id. You can hardcode any id you like, but use the id as the HashMap key. x Accept any value for the name fields x Only accept valid values for age, email and ssn x Create a Person with the valid input

3. Notes on validation. Here is a list of validation checks you can perform. Some are easier to implement than others, and there are many ways to correctly validate these aspects of the fields. Implement as many as you can. Age entered by user x Must be an integer greater than 16 Email address string entered by user x String must contain a '@' and at least one '.' x A '.' must follow the '@' x String must only contain one '@' Social Security Number string entered by user x String must contain two '-' characters in the correct position x The length of the string must be 11 x String must contain only digits or numbers. If you encounter invalid data, log it using the logging API of Java. (Do not use System.out.println(); ) Property Data Type id Integer firstName String middleName String lastName String email String ssn String age Integer

4. Static variables x Keep track of the highest age entered for a Person in a static variable.

5. Create subclasses for Instructor and Student x Instructors should have a Department x Students should have a Major x Generate getters and setters.

6. Add the Person, the Student and the Instructor to a HashMap. x In the driver program, create a Student and an Instructor (you don't need to prompt for input) x Add these three instances to a HashMap

7. Output the following after creating each person: x Loop through the HashMap and display x The person's full name and what kind of Person are they x The person's email domain x The last 4 digits of the person's Social Security Number x Whether the person is the oldest in the collection x 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_2

Step: 3

blur-text-image_3

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Describe the ABC model of behavioral therapy and give examples.

Answered: 1 week ago

Question

years ago. d Only using studies which feature empirical data.

Answered: 1 week ago

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago

Question

=+What is the extent of the use of each type of IE?

Answered: 1 week ago