2015-11-15 15:51:35 -08:00

30 lines
863 B
Java

// typeinfo/Person.java
// ©2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// A class with a Null Object.
import onjava.*;
class Person {
public final String first;
public final String last;
public final String address;
// etc.
public Person(String first, String last, String address){
this.first = first;
this.last = last;
this.address = address;
}
@Override
public String toString() {
return "Person: " + first + " " + last + " " + address;
}
public static class NullPerson
extends Person implements Null {
private NullPerson() { super("None", "None", "None"); }
@Override
public String toString() { return "NullPerson"; }
}
public static final Person NULL = new NullPerson();
}