/* CityEntry.java 1.0 */ /* by Sharon Tuttle */ /* last modified: 2-18-03 */ abstract class CityEntry { /*------------------------------------ fields -------------------------------------*/ private String name; private String address; private String phone; /*------------------------------------- accessors --------------------------------------*/ String getName() { return this.name; } String getAddress() { return this.address; } String getPhone() { return this.phone; } /*--------------------------------------- modifiers ------------------------------------------*/ void setName(String nm) { this.name = nm; } void setAddress(String addr) { this.address = addr; } void setPhone(String ph) { this.phone = ph; } /*------------------------------------------------ abstract methods (any subclass MUST provide an implementation of!) --------------------------------------------------*/ abstract String specialToString(); abstract String specialGetPhone(); /*-------------------------------------- other methods ---------------------------------------*/ /*----------------------------------------------------- isABusiness Purpose: returns true if this item of type CityEntry is a BusinessEntry object --- returns false otherwise. (also serves as a simple example of Java's instanceOf operator) -----------------------------------------------------*/ boolean isABusiness() { if (this instanceof BusinessEntry) { return true; } else { return false; } } }