In Java Programming: Example, 8-8, defined the class Person to store the name of a person. The methods that we included merely set the name and print the name of a person. Redefine the class Person so that, in addition to what the existing class does, ypu can: 1. Set the last name only. 2. Set the first name only. 3 Set the middle name. 4. Check whether a given last name is the same as the last name of this person. 5. Check wether a given first name is the same as the first name of this person. 6. Check whether a given middle name is the same as the middle name of thi person. 7. Add the method equals that returns true if two objects contain the same first, middle, and last name. 8. Add the method makeCopy that copies the instance variables of a Person object into another Person object. 9. Add the method getCopy that creates and returns the address of the object, which is a copy of another Person object. 10. Add a copy constructor. 11. Write the definitions of the methods of the class Person to implement the operations for this class. 12. Write a progrsm that tests various operations pf the class Person. Here's Example 8-8 of the Person Class: public class Person private String firstName, private String lastName //Default Constructor pubic Person() {firstName = " " ; lastName = " "; } //Construcotr with parameters public Person(String first, String last) { setName(first, last); } //Method to output the first name and last name public String toString() { return (firstName + " " + lastName); } //method to set first name and last name public void setName(String first, String last) { firstName = first; lastName last; } //Method to return the firstName public String getFirstName() { return firstName; } //Method to return the lastName public String getLastNme() { return lastName; }
In Java
1. Set the last name only.
2. Set the first name only.
3 Set the middle name.
4. Check whether a given last name is the same as the last name of this person.
5. Check wether a given first name is the same as the first name of this person.
6. Check whether a given middle name is the same as the middle name of thi person.
7. Add the method equals that returns true if two objects contain the same first, middle, and last name.
8. Add the method makeCopy that copies the instance variables of a Person object into another Person object.
9. Add the method getCopy that creates and returns the address of the object, which is a copy of another Person object.
10. Add a copy constructor.
11. Write the definitions of the methods of the class Person to implement the operations for this class.
12. Write a progrsm that tests various operations pf the class Person.
Here's Example 8-8 of the Person Class:
public class Person
private String firstName,
private String lastName
//Default Constructor
pubic Person()
{firstName = " " ;
lastName = " ";
}
//Construcotr with parameters
public Person(String first, String last)
{
setName(first, last);
}
//Method to output the first name and last name
public String toString()
{
return (firstName + " " + lastName);
}
//method to set first name and last name
public void setName(String first, String last)
{
firstName = first;
lastName last;
}
//Method to return the firstName
public String getFirstName()
{
return firstName;
}
//Method to return the lastName
public String getLastNme()
{
return lastName;
}

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images









