Question: Course: Data structures and algorithm Write the code for a class called TitledName that extends Name. An instance can have a title of Dr. ,

Course: Data structures and algorithm

Write the code for a class called TitledName that extends Name. An instance can have a title of Dr. , Prof., or no title (a blank).

Your class should have the following methods:

a. A default constructor.

b. A constructor with both a first and a last name, and a title.

c. get() and set() methods for the instance variables.

d. A toString() method.

e. An equals() method. Two instances are equal if they have

f. the same first and last names.

g. A compareTo() The method should compare using normal alphabetical order. Your method should compare last names. If two instances have the same last names then the first names should be compared.

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!