Three error-filled Java programs. Customer class is inherited from Person class. CustomerClassDemo.java is a simple program to demonstrate an object of Customer class. There are
Three error-filled Java programs. Customer class is inherited from Person class. CustomerClassDemo.java is a simple program to demonstrate an object of Customer class. There are five errors spreaded among the three Java programs.
CustomerClassDemo.java
/** This program demonstrates a solution to the Person and Customer Classes programming challenge. */
public class CustomerClassDemo { public static void main(String[] args) { // Create a Customer object for Julie James. Customer myCustomer = new Customer("Julie James", "123 Main Street", "555-1212", "147-A049", true); // Display the object's data. System.out.println("Name: " + myCustomer.name()); System.out.println("Address: " + myCustomer.getAddress()); System.out.println("Telephone: " + myCustomer.getPhone()); System.out.println("Customer Number: " + myCustomer.getCustomerNumber()); if (myCustomer.getMailingList()) System.out.println("Mailing List: YES"); else System.out.println("Mailing List: NO"); } }
Customer.java
/** The Customer class stores data about a person who is a customer for the Person and Customer Classes programming challenge. */
public class Customer expends Person { private String customerNumber; // Customer number private boolean mailingList; // Add to mailing list?
/** The no-arg constructor initializes the object with empty strings for name, address, phone, and customerNumber. The mailingList field is set to false. */ public Customer() {
customerNumber = ""; mailingList = false; }
/** This constructor initializes the object with a name, address, a phone number, a customer number, and mailing list status. @param n The name. @param a The address. @param p The phone number. @param c The customer number. @param m Mailing list status (true = yes, false = no). */ public Customer(String n, String a, String p, String c, boolean m) { super(a, n, p); customerNumber = c; mailingList = m; }
/** The setCustomerNumber method sets the customerNumber field. @param c The customer number to use. */ public void setCustomerNumber(String c) { customerNumber = c; }
/** The setMailingList method sets the mailing list status. @param m The mailing list status (true = add to mailing list, false = do not add to mailing list). */ public void setMailingList(boolean m) { mailingList = m; }
/** The getCustomerNumber method retrns the customer number. @return The customer number. */
public String getCustomerNumber() { return customerNumber; }
/** The getMailingList method retrns the mailing list status. @return The mailing list status. */ public boolean getMailingList() { return mailingList; } }
Person.java
/** The Person class stores data about a person for the Person and Customer Classes programming challenge. */ public class Person { private String name; // The person's name private String address; // The person's address private String phone; // The person's phone number
/** The no-arg constructor initializes the object with empty strings for name, address, and phone. */
public Person() { name = ""; address = ""; phone = ""; }
/** This constructor initializes the object with a name, address, and a phone number. @param n The name. @param a The address. @param p The phone number. */
public Person(String n, String a, String p) { name = n; address = a; phone = p; }
/** The setName method sets the name field. @param n The name to use. */
public void setName(String n) { name = n; }
/** The setAddress method sets the address field. @param a The address to use. */
public void setAddress(String a) { address = a; }
/** The setPhone method sets the phone field. @param p The phone number to use. */
public void setPhone(String p) { phone = p; }
/** The getName method returns the name field. @return The name. */ public String getName() { return name; }
/** The getAddress method returns the address field. @return The address. */ public void getAddress() { return address; }
/** The getPhone method returns the phone field. @return The phone number. */ public String getPhone() { return phone; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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