Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Person class This class implements the Comparable interface ( details below ) . This class has instance variables and accessor methods for Date born, Date

Person class
This class implements the Comparable interface (details below).
This class has instance variables and accessor methods for Date born, Date died, and Name name. It has the following methods:
public Person (Date born, Name name): This constructor throws IllegalPersonException exceptions if either born or name is null.
public void die(Date dateOfDeath): this method sets the died instance variable to the dateOfDeath provided.
public boolean isAlive(): this method returns true if the Person is alive; otherwise returns false.
public int compareTo(Person p): this method satisfies the requirements from implementing the Comparable interface. Younger people are "larger". Note: this method must use its born variable's compareTo(Date d) method.
This class overrides the public String toString() method, which returns a String in one of these two exact formats:
a) Alive people example: "Tiger Woods was born 1975-12-30 and is still alive"
b) Dead people example: "Albert Einstein was born 1879-03-14 and died 1955-04-18"
Use the name variable's getPrettyName() method, and the born/died getYyyyMmDd() method.

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

=+ how might this lead to faster growth in productivity?

Answered: 1 week ago