Question
Lab 8 Inheritance Assignment Download the Lab8.zip file from Blackboard. Unzip this file and open it in IntelliJ. The file contains the following Java files:
Lab 8 Inheritance
Assignment
Download the Lab8.zip file from Blackboard. Unzip this file and open it in IntelliJ. The file contains the following Java files:
Address an address class
Main main method for creating objects and generating and printing reports
PersonName a person name class
PersonRecord a class that contains a persons, name, address, and phone numbers
PhoneNumber a phone number class
Your assignment is to create a new class called CustomerRecord. This class describes a companys customer and is derived from PersonRecord. It contains the following additional fields:
customerID a customer ID (type: String)
creditCardType a credit card type (ex: Visa, MC, Amex, etc.) (type: String)
creditCardNumber a credit card number (type: String)
creditCardDate a credit card date (ex: 12/19) (type: String)
Create the new class with the above fields, a constructor, and getters and setters. (Use the Generate capability in IntelliJ. Compile the new code and fix any compilation issues.
Once it compiles uncomment the code in the main() method to test your new class. If there are still compilation errors, make appropriate changes to the CustomerRecord class, not to main(). Run the report and verify your new class.
Submit the CustomerRecord.java file (via Blackboard) to your instructor for grading.
Example Output
Name: Dr. Adelaide Penelope Aardvark
Address: 120 North Tulip Tree Drive
Jackson, OH 45640
Home Phone: (740) 555-1005
Work Phone: (740) 555-2356
Mobile Phone: (614) 555-9723
Customer ID: 123456
Credit card type: Visa
Credit card number: 4111-1111-1111-1111
Credit card date: 12/25
Process finished with exit code 0
-------------------------------------------------
public class Address { private String streetAddress; private String city; private String state; private String zip; public Address(String streetAddress, String city, String state, String zip) { this.streetAddress = streetAddress; this.city = city; this.state = state; this.zip = zip; } public String getStreetAddress() { return this.streetAddress; } public void setStreetAddress(String streetAddress) { this.streetAddress = streetAddress; } public String getCity() { return this.city; } public void setCity(String city) { this.city = city; } public String getState() { return this.state; } public void setState(String state) { this.state = state; } public String getZip() { return this.zip; } public void setZip(String zip) { this.zip = zip; } }
-------------------------------------------
public class Main { public Main() { } public static void main(String[] args) { new Address("120 North Tulip Tree Drive", "Jackson", "OH", "45640"); new PersonName("Dr.", "Adelaide", "Penelope", "Aardvark", (String)null); new PhoneNumber(740, 555, 1005); new PhoneNumber(740, 555, 2356); new PhoneNumber(614, 555, 9723); }
----------------------------------------------------------
public class PersonName { private String title; private String firstName; private String middleName; private String lastName; private String suffix; public PersonName(String title, String firstName, String middleName, String lastName, String suffix) { this.title = title; this.firstName = firstName; this.middleName = middleName; this.lastName = lastName; this.suffix = suffix; } public String getTitle() { return this.title; } public void setTitle(String title) { this.title = title; } public String getFirstName() { return this.firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getMiddleName() { return this.middleName; } public void setMiddleName(String middleName) { this.middleName = middleName; } public String getLastName() { return this.lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getSuffix() { return this.suffix; } public void setSuffix(String suffix) { this.suffix = suffix; } public String toString() { String fullName = this.firstName; if(this.middleName != null && !"".equals(this.middleName)) { fullName = fullName + " " + this.middleName; } fullName = fullName + " " + this.lastName; if(this.title != null && !"".equals(this.title)) { fullName = this.title + " " + fullName; } if(this.suffix != null && !"".equals(this.suffix)) { fullName = fullName + " " + this.suffix; } return fullName; } }
--------------------------------------------------------
public class PersonRecord { private PersonName name; private Address address; private PhoneNumber homePhone; private PhoneNumber workPhone; private PhoneNumber cellPhone; public PersonRecord(PersonName name, Address address, PhoneNumber homePhone, PhoneNumber workPhone, PhoneNumber cellPhone) { this.name = name; this.address = address; this.homePhone = homePhone; this.workPhone = workPhone; this.cellPhone = cellPhone; } public PersonName getName() { return this.name; } public void setName(PersonName name) { this.name = name; } public Address getAddress() { return this.address; } public void setAddress(Address address) { this.address = address; } public PhoneNumber getHomePhone() { return this.homePhone; } public void setHomePhone(PhoneNumber homePhone) { this.homePhone = homePhone; } public PhoneNumber getWorkPhone() { return this.workPhone; } public void setWorkPhone(PhoneNumber workPhone) { this.workPhone = workPhone; } public PhoneNumber getCellPhone() { return this.cellPhone; } public void setCellPhone(PhoneNumber cellPhone) { this.cellPhone = cellPhone; } }
------------------------------------------------------------------
public class PhoneNumber { private int areaCode; private int prefix; private int lineNumber; public PhoneNumber(int areaCode, int prefix, int lineNumber) { this.areaCode = areaCode; this.prefix = prefix; this.lineNumber = lineNumber; } public int getAreaCode() { return this.areaCode; } public void setAreaCode(int areaCode) { this.areaCode = areaCode; } public int getPrefix() { return this.prefix; } public void setPrefix(int prefix) { this.prefix = prefix; } public int getLineNumber() { return this.lineNumber; } public void setLineNumber(int lineNumber) { this.lineNumber = lineNumber; } public String toString() { return "(" + this.areaCode + ") " + this.prefix + "-" + this.lineNumber; }
-------------------------------------------------
public class CustomerRecord extends PersonRecord { private String customerID; private String creditCardType; private String creditCardNumber; private String crreditCardDate; public CustomerRecord(PersonName name, Address address, PhoneNumber homePhone, PhoneNumber workPhone, PhoneNumber cellPhone, String customerID, String creditCardType, String creditCardNumber, String crreditCardDate) { super(name, address, homePhone, workPhone, cellPhone); this.customerID = customerID; this.creditCardType = creditCardType; this.creditCardNumber = creditCardNumber; this.crreditCardDate = crreditCardDate; } public String getCustomerID() { return this.customerID; } public void setCustomerID(String customerID) { this.customerID = customerID; } public String getCreditCardType() { return this.creditCardType; } public void setCreditCardType(String creditCardType) { this.creditCardType = creditCardType; } public String getCreditCardNumber() { return this.creditCardNumber; } public void setCreditCardNumber(String creditCardNumber) { this.creditCardNumber = creditCardNumber; } public String getCrreditCardDate() { return this.crreditCardDate; } public void setCrreditCardDate(String crreditCardDate) { this.crreditCardDate = crreditCardDate; } }
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