0% found this document useful (0 votes)
7 views2 pages

Java Person and Customer Classes

The document defines two Java classes: Person and Customer. The Person class includes private fields for name, address, and number, along with constructor, accessor, and mutator methods. The Customer class extends Person, adding fields for customerNumber and receiveMail, along with its own constructor and methods for accessing and modifying these new fields.

Uploaded by

7punchisjimenez
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Java Person and Customer Classes

The document defines two Java classes: Person and Customer. The Person class includes private fields for name, address, and number, along with constructor, accessor, and mutator methods. The Customer class extends Person, adding fields for customerNumber and receiveMail, along with its own constructor and methods for accessing and modifying these new fields.

Uploaded by

7punchisjimenez
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1

public class Person {


private String name;
private String address;
private String number;

// Constructor
public Person(String n, String a, String num) {
name = n;
address = a;
number = num;
}

// Accessor methods
public String getName() {
return name;
}

public String getAddress() {


return address;
}

public String getNumber() {


return number;
}

// Mutator methods
public void setName(String n) {
name = n;
}

public void setAddress(String a) {


address = a;
}

public void setNumber(String n) {


number = n;
}
}

2
public class Customer extends Person {
private String customerNumber;
private boolean receiveMail;

public Customer(String name, String address, String number, String customerNumber,


boolean receiveMail) {
super(name, address, number);
[Link] = customerNumber;
[Link] = receiveMail;
}

public String getCustomerNumber() {


return customerNumber;
}

public boolean getReceiveMail() {


return receiveMail;
}

public void setCustomerNumber(String customerNumber) {


[Link] = customerNumber;
}

public void setReceiveMail(boolean receiveMail) {


[Link] = receiveMail;
}
}

You might also like