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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started