Question
1. The following interface and classes have to do with the storage of information that may appear on a mailing label. Design and implement each
1. The following interface and classes have to do with the storage of information that may appear on a mailing label. Design and implement each of the described classes below.
public interface AddrLabelInterface {
String getAttnName(); String getTitle(); // Mr., Mrs., etc. String getName(); String getNameSuffix(); // e.g., Jr., III String getProfessionalSuffix(); // O.D. String getStreet(); String getSuiteNum(); String getCity(); String getState(); String getZipCode();
}
Step 1
(doctor of optometry)
Create an abstract AddrLabel class that implements only the following methods of the AddrLabelInterface to return an empty string: getAttnName(), getTitle(), getNameSuffix(), getProfessionalSuffix(), and getSuiteNum(). The rest of the methods should be left unimplemented (i.e., as abstract methods).
Step 2
Create a class named FriendAddrLabel declared as a (concrete) subclass of the abstract AddrLabel class. The FriendAddrLabel class should be designed to store only the Name, Street, City, State and ZipCode fields.
e.g., Jeff Taylor
143 Main St. Towson, MD 21250
Step 3
Create a class named CompanyAddrLabel declared as a (concrete) subclass of the abstract AddrLabel class. The CompanyAddrLabel class should be designed to store only the AttnName, Title, CompanyName, Street, City, State and ZipCode fields.
e.g., ATTN: Rebecca Rollins A1 Technology 92 Autumn Drive Keene, NH 03431
1
Step 4
Create a class named ProfessionalAddrLabel declared as a (concrete) subclass of the abstract AddrLabel class. The ProfessionalAddrLabel class should be designed to store only the Name, ProfessionalSuffix, Street, Suite, City, State and ZipCode fields.
e.g., Sarah K. Phillips, O.D.
100 Oak Street, Suite 904 Omaha, NE 68007
Design and implement a class named LabelGenerator that is constructed to contain an object of type AddrLabelInterface. The class should contain the following method (in addition to any other supporting methods),
public String[] getLabelLines()
that returns in the array of strings the address lines as they should be printed for the given address label type.
Create a simple main program that creates a number of address object types, and stores in an array of elements of type AddrLabelInteface. Using a simple for loop (i.e., enhanced for loop), display each label one by one in the array.
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