bool sameName(String name) bool isVotingAge() Date lastVotedOn()
interface Voter {
bool sameName(String name);
bool isVotingAge();
Date lastVotedOn();
}
interface Dictionary<K, V> {
public void put(K key, V value);
public void delete(K key);
public V find(K key);
}
class Citizen
implements Voter
extends Person {
bool sameName(String name) { ... }
bool isVotingAge() { ... }
Date lastVotedOn() { ... }
bool isNaturalized() { ... }
// and so on
}
interface RichVoter extends Voter BigInteger campainContributions();
|
|
|
interfaceComparableint compareTo(Object o); public interfaceDestroyablevoid destroy(); boolean isDestroyed(); public interfaceReadableint read(CharBuffercb);
class Card implementsComparableint compareTo(Object o) { ... } // and so on. class SecurityCertificate implementsDestroyable,Readablevoid destroy() { ... } boolean isDestroyed() { ... } int read(CharBuffer cb) { ... } // and so on.
boolean beats(Comparablex) { ... } void validate(Destroyabletag) { ... } Message read(Readableinput) { ... }
SecurityCertificate ticket = new SecurityCertificate() validate(ticket) Message m = read(ticket)