PersonData.java:
public class PersonData { private String firstname; private String lastname; private String address; private String city; private String zip; private String phone; /** * user constructor * @param firstname of person * @param lastname of person */ PersonData(String firstname, String lastname){ this.firstname = firstname; this.lastname = lastname; } /** * getter method for first name * @return first name of person */ public String getFirstname() { return firstname; } /** * setter method for first name * @param firstname of person to be set */ public void setFirstname(String firstname) { this.firstname = firstname; } /** * getter method for last name * @return lastname of user */ public String getLastname() { return lastname; } /** * setter method for lastname * @param lastname of person */ public void setLastname(String lastname) { this.lastname = lastname; } /** * getter method for address * @return address of person */ public String getAddress() { return address; } /** * setter method for address * @param address of person to be set */ public void setAddress(String address) { this.address = address; } /** * getter method for city * @return city of person */ public String getCity() { return city; } /** * setter method for city * @param city of person */ public void setCity(String city) { this.city = city; } /** * getter method for xip * @return zip of person */ public String getZip() { return zip; } /** * setter method for zip * @param zip of person */ public void setZip(String zip) { this.zip = zip; } /** * getter method for phone * @return phone of person */ public String getPhone() { return phone; } /** * setter method for phoone * @param phone of person to be set */ public void setPhone(String phone) { this.phone = phone; } @Override public String toString() { return " " + "firstname='" + firstname + '\'' + ", lastname='" + lastname + '\'' + ", address='" + address + '\'' + ", city='" + city + '\'' + ", zip='" + zip + '\'' + ", phone='" + phone + '\''; } }
CustomerData.java:
public class CustomerData extends PersonData{ private int customerNumber; private boolean mailingList; /** * parameterize constructor * @param firstname of customer * @param lastname of customer * @param customerNumber of customer */ CustomerData(String firstname, String lastname, int customerNumber){ super(firstname, lastname); this.customerNumber = customerNumber; } /** * getter method for customer number * @return customer number */ public int getCustomerNumber() { return customerNumber; } /** * setter method for customer number * @param customerNumber of customer */ public void setCustomerNumber(int customerNumber) { this.customerNumber = customerNumber; } /** * getter method for maillist * @return */ public boolean isMailingList() { return mailingList; } /** * setter method of maillist * @param mailingList to be set */ public void setMailingList(boolean mailingList) { this.mailingList = mailingList; } @Override public String toString() { return "C " + "customerNumber=" + customerNumber + ", mailingList=" + mailingList; } }
Main.java:
public class Main { public static void main(String[] args){ // create new customer CustomerData customer = new CustomerData("John","Sharma", 30); // print customer details System.out.println("Customer id: "+customer.getCustomerNumber()); System.out.println("Customer name: "+customer.getFirstname()+" "+customer.getLastname()); } }
Output:
7. PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName...
7. PersonData and CustomerData classes Design a class named PersonData with the following member variables : lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables . Next, design a class named CustomerData, which is derived from the PersonData class . The CustomerData class should have the following member variables : customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool....
Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes...
WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.1. Employee and ProductionWorker ClassesDesign a class named Employee. The class should keep the following information in• Employee name• Employee number• Hire dateWrite one or more constructors and the appropriate accessor and mutator functions for the class.Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:• Shift (an integer)• Hourly pay rate (a double )The workday...
this is java m. please use netbeans if you can. 7. Person and Customer Classes Design a class named Person with fields for holding a person's name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields. Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the cus- tomer wishes to...
Using JAVA* Design a class named Person with fields for holding a person’s name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class’s fields. Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write one or more constructors and the appropriate mutator...
Code the following Program in C++ Define a class named Payment that contains a member variable of type float that stores the amount of the payment and appropriate accessor and mutator methods. Also create a member function named paymentDetails that outputs an English sentence that describes the amount of the payment. Next define a class named CashPayment that is derived from Payment. This class should redefine the paymentDetails function to indicate that the payment is in cash. Include appropriate constructor(s)....
in C++: Create a class named Student that has three member variables: name - string that stores the name of the student numClasses - integer that tracks how many courses the student is currently enrolled in, this number must be between 1 and 100. classList - an array of strings of size 100 used to store the names of the classes that the student is enrolled in Write the appropriate constructor(s), mutator and accessor functions for the class along with...
Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type double that stores the amount of the payment and appropriate accessor (getPaymentAmount() ) and mutator methods. Also create a method named paymentDetails that outputs an English sentence to describe the amount of the payment. Override toString() method to call the paymentDetails() method to print the contents of payment amount and any other details not included in paymentDetails(). Define a class named CashPayment that is...
Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...
Design a class named Student. The Student class should have a Firstname, a Lastname, an Address, an email address, a major and a GPA. Determine the data types for each property, then create the class diagram and write the pseudo-code that defines the class. You can use java language for pseudo-code