/** *
* MailBox.java * * Revisions: 1.0 Oct. 01, 2002 * Created the MailBox class * 1.1 Oct. 05, 2002 * Compiled, Finished, Commented * ** * Collaboration Statement: * I worked on the homework assignment alone, using only * course materials. * * Created with JCreatorLE, some indents are off when viewed through notepad * or EMACS * * @author Jose Manuel Caban * @version Version 1.1, Oct. 05, 2002 */ import java.util.Vector; import java.util.Enumeration; public class MailBox implements P3Type{ public static final boolean bDebug = false; //there's nothing to debug //that bDebug can handle private String strLName; private String strFName; private Vector vMail; //////////////// //Constructors// //////////////// /** *Constructor for MailBox *@param last the value for strLName *@param first the value for strFName */ public MailBox(String last, String first){ strLName = last; strFName = first; vMail = new Vector(); } /////////////////////// //Accessors/Modifiers// /////////////////////// /** *Modifier for strLName *@param strLName the value to set this.strLName */ public void setStrLName(String strLName){ this.strLName = strLName; } /** *Accessor for strLName *@return the value of strLName */ public String getStrLName(){ return strLName; } /** *Modifier for strFName *@param strFName the value to set this.strFName */ public void setStrFName(String strFName){ this.strFName = strFName; } /** *Accessor for strFName *@return the value of strFName */ public String getStrFName(){ return strFName; } /////////// //Methods// /////////// /** *Adds mail to the persons box *@param mail, the mail to be added */ public void addMail(Mail mail){ vMail.add(mail); } /** *clear vector and return enumeration of all mail *@return an enumeration of the mail a person has */ public Enumeration getMail(){ Vector vTemp = (Vector)vMail.clone(); Enumeration enum = vTemp.elements(); vMail.clear(); return enum; } /** *toString() override *@return the amount of mail the person has as a string */ public String toString(){ return (getStrFName() + " " + getStrLName() + " has " + vMail.size() + " piece" + (vMail.size()==1?"":"s") + /*I used ==1 because when its 0 it should be pieces not piece*/ " of mail."); } /** *@return true if both Mailboxes are owned by the same person */ public boolean equals(Object obj){ if(!(obj instanceof MailBox)){ return false; } MailBox temp = (MailBox)obj; if(!(this.getStrFName().equals(temp.getStrFName()))){ return false; } if(!(this.getStrLName().equals(temp.getStrLName()))){ return false; } return true; } /*******************************************************/ /** * Debugging main for class MailBox. * This method will rigorously test my code. * *