/** * Write a description of class PhoneNumber here. * * @author Jeff Pittges * @version 8-MAR-2007 */ public class PhoneNumber { // instance variables private int areaCode = 0; private int exchange = 0; private int extension = 0; /** * Constructor for objects of class PhoneNumber */ public PhoneNumber(int _areaCode, int _exc, int _ext) { // initialise instance variables this.areaCode = _areaCode; this.exchange = _exc; this.extension = _ext; } void setAreaCode(int newAreaCode) { this.areaCode = newAreaCode; } int getAreaCode() { return this.areaCode; } void setExchange(int newExchange) { this.exchange = newExchange; } int getExchange() { return this.exchange; } void setExtension(int newExt) { this.extension = newExt; } int getExtension() { return this.extension; } public void copyFrom(PhoneNumber pnum) { this.setAreaCode(pnum.getAreaCode()); this.setExchange(pnum.getExchange()); this.setExtension(pnum.getExtension()); } public void swap(PhoneNumber pnum) { PhoneNumber tmp = new PhoneNumber(555, 555, 1212); tmp.copyFrom(this); this.copyFrom(pnum); pnum.copyFrom(tmp); } }