Question: Download the attached Name.java file and add the equals() method from segment C.24 page 917. #14. If sue and susan are two instances of the

Download the attached Name.java file and add the equals() method from segment C.24 page 917.

#14. If sue and susan are two instances of the class Name, what if() statement can decide whether they represent the same name?

Write a Java program to do this with JavaDoc. Instead of sue and susan use variables name0 as your name, name1 as "Mr." "Reed", and name2 as your name again. Then test for equal names as follows:

  • your name equals my name (Mr. Reed) // name0.equals( name1 )
  • your name equals your name // name0.equals( name2 )
  • your name == your name // name0 == name2

Attach the updated Name.java, the lab program, and copyAndPasted output. SR

Attached file

/** A class that represents a person's name. Listing B-1 in Segment B.16 of Appendix B. @author Frank M. Carrano @author Timothy M. Henry @version 5.0 */ public class Name //implements Comparable { private String first; // First name private String last; // Last name public Name() { } // end default constructor public Name(String firstName, String lastName) { first = firstName; last = lastName; } // end constructor public void setName(String firstName, String lastName) { setFirst(firstName); setLast(lastName); } // end setName public String getName() { return toString(); } // end getName public void setFirst(String firstName) { first = firstName; } // end setFirst public String getFirst() { return first; } // end getFirst public void setLast(String lastName) { last = lastName; } // end setLast public String getLast() { return last; } // end getLast public void giveLastNameTo(Name aName) { aName.setLast(last); } // end giveLastNameTo public String toString() { return first + " " + last; } // end toString } // end Name

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!