Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Person Data L10 marks] Step 1 Person Data, CustomerData [12 marks] Design a c

ID: 3827189 • Letter: 1

Question

1. Person Data L10 marks] Step 1 Person Data, CustomerData [12 marks] Design a class named PersonDatawwith 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 CustomeDatam 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. It will be set to true if the customer wishes to be on a mailing list, or false if the customer does not wish to be on a mailing list. Write appropriate accessor and mutator functions for these member variables. Demonstrate an object of the CustomerData class in a simple program. Sample output Customer #1 Last Name: Smith First Name: Joan Address: 123 M Street ain City: Smithville

Explanation / Answer

class PersonData

{

public String lastName;

public String firstName;

public String address;

public String city;

public String state;

public int zip;

public int phone;

public void accessor(String lastName,String firstName,String address,String city,String state,int zip,int phone)

{

this.lastName=lastName;

this.firstName=firstName;

this.address=address;

this.city=city;

this.state=state;

this.zip=zip;

this.phone=phone;

}

public void Mutator()

{

System.out.println("Customer Data are:");

System.out.println("Last Name Of Customer Is:"+lastName);

System.out.println("First Name Of Customer Is:"+firstName);

System.out.println("Address Of Customer Is:"+address);

System.out.println("City Of Customer Is:"+city);

System.out.println("State Of Customer Is:"+state);

System.out.println("ZipCode Of Customer Is:"+zip);

System.out.println("Phone Number Of Customer Is:"+phone);

}

}

class CustomerData extends PersonData

{

int customerNo;

Boolean mailingList;

public void accessor(int customerNo,Boolean mailingList)

{

super.accessor();

this.customerNo=customerNo;

this.mailingList=mailingList;

}

public void mutator()

{

super.mutator();

System.out.println("Customer Number Is:"+customerNo);

if(customerNo==true)

{

System.out.println("Yes");

}

else

{

System.out.println("No");

}

}

}

class PreferredCustomer extends CustomerData

{

double purchasesAmount;

double discountLevel;

public void accessor(double purchasesAmount,double discountLevel)

{

super.accessor();

this.purchasesAmount=purchasesAmount;

this.discountLevel=discountLevel;

}

public void Multator()

{

super.mutator();

System.out.println("Purchase Amount Is:"+purchasesAmount);

System.out.println("Discount Level Is:"+discountLevel);

}

}

class simple

{

public static void main(String args[])

{

CustomerData cd=new CustomerData();

PreferredCustomer pc=new PreferredCustomer();

cd.accessor("Smith","Joan","123 Main Street","Smithville","NC",99999,12345);

pc.accessor("Smith","Joan","123 Main Street","Smithville","NC",99999,12345,2536,3000,10);

cd.mutator();

}

}