Question: JAVA Create a project called Person_FirstName_LastName. This project will have two Java files: Person and PersonDemo. PersonDemo will have a main method used to test

JAVA

Create a project called Person_FirstName_LastName. This project will have two Java files: Person and PersonDemo. PersonDemo will have a main method used to test the custom Person class.

The Person class has a static int field to hold a social security number generator that is initialized to 0. This class will also have an int field to hold a social security number that comes from this generator. Whenever a new Person object is constructed, the static field should be incremented first and then assigned to the non-static field. Additionally, the Person class should have a String field to hold a first and last name.

Make a copy method that takes an object of the Person class and constructs a new Person object using the name of the passed in object. Make a toString method that will print something equivalent to the following when an object of the Person class is passed into a print statement:

s social security number is .

Make an additional method besides the main method in PersonDemo that either accepts a Person object or returns a Person object. If this method accepts an object, use the copy method to make a copy of that object before manipulating its values. If this method returns an object, use the copy method to make a copy of that object before returning it.

Use the main method in PersonDemo to construct three Person objects. Make a call to the additional method, using one of these objects with that method. Lastly, print the three objects to the console.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!