Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions