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

JAVA PROGRAMING Design a class named person with fields for holding a person\'s

ID: 3808962 • Letter: J

Question

JAVA PROGRAMING

Design a class named person with fields for holding
a person's name,address,and telephone number.Write one
or more constrctors 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 and
accestor methods for the class's fields.Demonstrate an
object of the customer class in a simple program

Explanation / Answer

Hi, Please find my implementation.

Please let me know in case of any issue.

############## Person.java #############

public class Person {

   private String name;

   private String address;

   private String phoneNumber;

  

   public Person() {

       name = "";

       address = "";

       phoneNumber = "";

   }

   public Person(String name, String address, String phoneNumber) {

       this.name = name;

       this.address = address;

       this.phoneNumber = phoneNumber;

   }

   public String getName() {

       return name;

   }

   public String getAddress() {

       return address;

   }

   public String getPhoneNumber() {

       return phoneNumber;

   }

   public void setName(String name) {

       this.name = name;

   }

   public void setAddress(String address) {

       this.address = address;

   }

   public void setPhoneNumber(String phoneNumber) {

       this.phoneNumber = phoneNumber;

   }

}

################ Customer.java ##########

public class Customer {

  

   private String number;

   private boolean isMaling;

  

   public Customer() {

       number = "";

       isMaling = false;

   }

   public Customer(String number, boolean isMaling) {

       this.number = number;

       this.isMaling = isMaling;

   }

   public String getNumber() {

       return number;

   }

   public boolean isMaling() {

       return isMaling;

   }

   public void setNumber(String number) {

       this.number = number;

   }

   public void setMaling(boolean isMaling) {

       this.isMaling = isMaling;

   }

  

   @Override

   public String toString() {

       return "Number: "+number+" is in Mailing list ? "+isMaling;

   }

}

############# CustomerTest.java #########

public class CustomerTest {

   public static void main(String[] args) {

      

       Customer c1 = new Customer("43212343", true);

      

       System.out.println(c1);

      

       c1.setMaling(false);

      

       System.out.println(c1);

      

   }

  

}

/*

Sample run:

Number: 43212343 is in Mailing list ? true

Number: 43212343 is in Mailing list ? false

*/