Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

OOP JAVA IN ECLIPSE~~~~~ Instructions: Create a class called Person with the properties listed: int id, String firstName, String middleName, String lastName, String email, String

OOP JAVA IN ECLIPSE~~~~~

Instructions:

  1. Create a class called Person with the properties listed: int id, String firstName, String middleName, String lastName, String email, String ssn, int age. The Person class should have getters and setters for all properties other than id. (You may use Eclipse to help you auto-generate these.)

    1. Person class should also have a getter for id

    2. Create a no-arg constructor for Person

    3. In addition to these getters and setters, Person should have the following instance methods:

      • String toString() returns full name, like "Edgar Allen Poe"

      • String getEmailDomain() returns the domain portion of an email (after the @)

      • String getLast4SSN() returns the last 4 digits of the Social Security Number

      • Add validation checking methods

        • static boolean validAge(String testAge)

          1. You will have to convert the testAge String to an int to store it after validation

        • static boolean validEmail(String testEmail)

        • static boolean validSSN(String testSSN)

for the age, email and ssn.You may 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.

  1. Notes on validation.

    1. Here is a list of validation checks you should perform. Some 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 little research on topic and include your answer. If there is, include your algorithm.

      • Age entered by user

        • The String entered must be an integer greater than 16

        • If the String is greater than 100 you should log an info message

      • Email address string entered by user

        • String must contain a '@' and at least one '.

        • A '.' must follow the '@

        • String must only contain one '@'

        • The domain name (the part after @ but before the first . )must be at least one character in length

    2. Clearly there are far more restrictions on email addresses than those listed above. See if you can think of any others that might be applicable. I will give out extra credit for especially clever email validation tests. Make sure to document and comment your ideas.

    3. 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

    4. If you encounter invalid data for any of these fields, log it using the logging API of Java. (Do not use System.out.println(); )

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

  1. Create a driver program PersonApp to test the class

    1. Prompt user for all Person properties except id. You can hardcode any id you like, but use the id as the HashMap key

    2. Accept any value for the name field

    3. Only accept valid values for age, email and ssn

    4. Create a Person with the valid input

  1. Create subclasses for Instructor and Student

    1. Instructors should have a Department

    2. Students should have a Major

    3. Generate getters and setters

  1. Add the Person, the Student and the Instructor to a HashMap.

    1. In the Driver, create a Student & an Instructor (Hardcoded, do not prompt for Input)

    2. Add each of these three instances (the hardcoded Student & Instructor, and previously created Person ) to a HashMap using the id as the key

  1. Perform the following after creating each person in the Driver:

    1. 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 Number

      • Whether the person is the oldest in the collection

      • The major for the Student, the department for the Instructor

Here is some sample output, to help you understand the end goal of the exercise (your prompts may look different than mine, dont worry about that as long as they are clear)

Enter person's first name Julie Enter person's middle name Theresa Enter person's last name Collins Enter person's email address jCollins@acme.com Enter person's SSN in ###-##-#### format 123-45-6789 Enter person's age 47

Julie Theresa Collins (Person) acme.com 6789 Oldest

Jane Marie Doe (Student) students.rowan.edu 4444 not oldest

Computer Science

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

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

Define the term Working Capital Gap.

Answered: 1 week ago

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Draft a business plan.

Answered: 1 week ago

Question

Describe the guidelines for appropriate use of the direct plan.

Answered: 1 week ago