Question
OOP IN JAVA PROJECT(I DONT KNOW HOW TO DO THIS :( :( :( :( ITS SUPPOSE TO BE IN ECLIPSE :/ and IDK HOW TO
OOP IN JAVA PROJECT(I DONT KNOW HOW TO DO THIS :( :( :( :( ITS SUPPOSE TO BE IN ECLIPSE :/ and IDK HOW TO USE ECLIPSE I ONLY KNOW HOW TO USE BLUEJ) Instructions:
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.)
Person class should also have a getter for id
Create a no-arg constructor for Person
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)
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.
Notes on validation.
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
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.
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
If you encounter invalid data for any of these fields, log it using the logging API of Java. (Do not use System.out.println(); )
Static variables: Keep track of the highest age entered for a Person in a static variable.
Create a driver program PersonApp 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 accept valid values for age, email and ssn
Create a Person with the valid input
Create subclasses for Instructor and Student
Instructors should have a Department
Students should have a Major
Generate getters and setters
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
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 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
Stephen J. Hartley (Instructor) rowan.edu 5555 not oldest Math/Science
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started