Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Systems On GPUs In Databases

Authors: Johns Paul ,Shengliang Lu ,Bingsheng He

1st Edition

1680838482, 978-1680838480

More Books

Students also viewed these Databases questions