public class Person
1: package inheritance;
3: /**
4: * Root class for a simple inheritanc ehierarchy.
5: * This class has both public and private methods.
6: * Student extends this class.
7: *
8: * @author Mark Young (A00000000)
9: */
10: public class Person {
12: /** Every Person has a name */
13: private String name;
15: /** Person requires a name */
16: public Person(String n) {
17: this.name = n;
18: }
20: /** return this Person's name */
21: public String getName() {
22: return this.name;
23: }
25: /** Change this Person's name */
26: public void setName(String nn) {
27: this.name = nn;
28: }
30: /** A method for children classes to inherit */
31: public void publicPersonMethod() {
32: System.out.println("\tin publicPersonMethod for " + this.name);
33: }
35: /** A method for children classes to inherit */
36: public void callingPrivatePersonMethod() {
37: System.out.println("\tin callingPrivatePersonMethod for " + this.name);
38: privatePersonMethod();
39: System.out.println("\tcallingPrivatePersonMethod done");
40: }
42: /** A method children classes can't call *directly* */
43: private void privatePersonMethod() {
44: System.out.println("\t\tin privatePersonMethod for " + this.name);
45: }
47: /** A method for children classes to replace entirely. */
48: public void replacedMethod() {
49: System.out.println("\tin replacedMethod for Person " + this.name);
50: }
52: /** A method for children classes to add to. */
53: public void revisedMethod() {
54: System.out.println("\tin revisedMethod for Person " + this.name);
55: }
57: /** A method to represent this Person using a String */
58: @Override
59: public String toString() {
60: return name;
61: }
63: }