Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will write a class that implements a contact boolk entry. For example, my iPhone (and pretty much any smartphone) has a

image text in transcribed
image text in transcribed
image text in transcribed
In this assignment, you will write a class that implements a contact boolk entry. For example, my iPhone (and pretty much any smartphone) has a contacts list app that allows you to store information about your friends, colleagues, and businesses. In later assignments, you wl have to implement this type of app (as a command line program, of course.) For now, you will just have to implement the building blocks for this app, namely, the Contact class The first name of the person The last name of the person The phone number of the person The street address of the person The city of the person The state of the person The Contact class should implement the Comparable interface. More on this later. Of course, you may implement private helper methods if it helps your implementation. A constructor that initializes all the fields with information. A constructor that initializes only the name and phone number accessor (getter) methods for all of the data members. an update method that allows the user to change all information. (They must change all of it). An overridden equals0 method that can tell if one Contact is the same as another. It should have the method signature public boolean equals (0bject obj); We will define one Contact as being the same as another contact if the first and last names both match. (Be careful! The parameter may not be a bona fide Contact!) An overridden toString) method that creates a printable representation for a Contact object. It should have the method signature: public String tostring); The String should be created in the following form: First name> cityate> A comparison method that looks like this: We will define this method in the following way: number. number. public int compareTo(Contact another) If the last name of "another" is lexicographically first, return a positive If the last name of "another" is lexicographically second, return a negative If the last names are the same and the first names are also the same, return 0. If the last names are the same and the first names are different, use the first names to determine the order. You must also declare the fact that Contact implements the Comparable interface You must also write a main program that tests each of these functions and You can choose to write this main program as a stand alone class that sits in the same directory as the Contact class, or you can just make the main program the main program of the Contact class itself. It doesn't matter much to me. What to submit: Your Contact.java file (Your main program class if it is separate

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

Students also viewed these Databases questions

Question

e. What difficulties did they encounter?

Answered: 1 week ago