Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Coding) IMPORTANT NOTE: USE ANY OF THE JAVA BUILT-IN CLASSES NOT PERMITTED, SUCH AS ArrayLists, Hash Maps, Date, Locale etc . need to code

JAVA Coding)

IMPORTANT NOTE: USE ANY OF THE JAVA BUILT-IN CLASSES NOT PERMITTED, SUCH AS ArrayLists, Hash Maps, Date, Locale etc. need to code whatever needed !!!

Write the implementation of the above-mentioned classes using inheritance/composition and according to the specifications and requirements given below:

There must be 2 different Java packages for the classes.

The first package will include the Address class.

The second package will include the GeographicAddress and PostOfficeBoxAddress

The Classes!

1) An Address represents information that can be used to contact a Party. A Party represents a person or an organization. In general, an Address may specify business, home, out-of-hours contact, emergency contact, and so on.

Each address specifies the usable time of the Address (i.e., limit the context in which the Address is applicable/valid. In other words, an Address has the following attributes: validFrom (String type representing a date in the format "YYYY-MM-DD") and validTo (String type representing a date in the format "YYYY-MM-DD") to specify and limit the use of an Address. Any address that falls out of the date limits is still and address, but considered to be obsolete. Notice that the dates can be future dates (yet to become valid). These Addresses are also obsolete for instance compared to the current date.

There are six (2) kinds of address objects: GeographicAddress and PostOfficeBoxAddress. They can be described as follows:

2) A GeographicAddress represents a geographic location at which a Party may be contacted. It is a postal address for the Party. Each GeographicAddress has an addressLine (String type), a city (String type), a regionOrState (String type), a zipOrPostCode (String type), and a Locale (Class type).[CANNOT USE JAVA BUILT_IN LOCALE CLASS, NEED TO WRITE A LOCALE CLASS] A Locale is inspired by the ISO 3166 standard (see the note on ISO 3166 below) and has an alphabetic two-letter country code (String type), a numeric country code (int type), and official English language country name (String type). For example: Canada Locale is: "CA" 124 "Canada" USA Locale is: "US" 840 "The United States of America"

Iran Locale is: "IR" 364 "The Islamic Republic of Iran" India Locale is: "IN" 356 "The Republic of India" Etc. Note on ISO 3166: The International Organization for Standardization (ISO) has created and maintains the ISO 3166 standard. This standard uses codes for the representation of names of countries and their subdivisions. The ISO 3166 standard contains three elements (simplified for this assignment): Element 1 is the two-letter country code (String type). Element 2 is the three-digit country code (int type). Element 3 is the English language country name (String type).

3) A PostOfficeBoxAddress (also known as P.O. box), is special type of a geographic address, that is uniquely addressable to a lockable box that is located on the premises (box lobby) of a post office station. In some regions, there is no door to door delivery of mail. The lockable box is accessible after hours by customers with a code to the box lobby's door keypad. Each PostOfficeBoxAddress has an addressLine (String type), a city (String type), a regionOrState (String type), a zipOrPostCode (String type), a Locale (as described above), and a boxLobbyDoorCode (int type).

---------------------------------------------------------------------------------------------------------------------

The toString() method must return a clear description and information of the object (For example: "This email address d..p@cleancode.app is valid from 2018-01-31 to 2021-12-31 and therefore still usable today").

The equals() method must first verify if the passed object (to compare to) is null and if it is of a different type than the calling object. The method would clearly return false if any of these conditions is true; otherwise, the comparison of the attributes is conducted to see if the two objects are actually equal. Two objects are equal if all the values of all their attributes are equal.

When accessing attributes from a base class, you must take full advantage of the permitted rights. For instance, if you can directly access an attribute by name from a base class, then you must do so instead of calling a public method from that base class to access the attribute.

3. The driver program (that contains the main() method) would utilize all of your classes. The driver class can be in a separate package or in any of the already existing packages. Besides the main() method, it should include a method called traceObsoleteAddresses(). This method takes four parameters, an array of Addresses, and three integer values representing a date (YYYY, MM, DD). The method must search in the array of Addresses and display all addresses that are/were obsolete in comparison the passed date. For example, if the passed date is 2021, 02, 15 and an Address has date limits of 1998-05-21 and 2010-10-03, then this Address is obsolete. Again, you should notice that Addresses can have future dates (yet to become effective). For instance, if the passed date is 2021, 02, 15 and an Address has date limits of 2021-10-18 and 2023-4-20, then this Address is also obsolete in relation to the passed date.

In the main() method you must:

Create various objects from the 2 classes, and display all their information (you must take advantage of the toString() method). Some of them must be obsolete addresses, limiting their usage only between validFrom and validTo dates.

Test the equality of some of the created objects using the equals() method.

an array of 4 to 6 these address objects (HINT: Do you need to add something else to the classes described above? If so; go ahead with that!) and fill that array with various objects from these classes (each class must have at least one entry in that array).

Call the traceObsoleteAddresses() method with the array created above, along with any date of. The method should trace and display all information of all obsolete Addresses along with their location (index) in the array.

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

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago