ComboLock - (combination==theLocker.getCombination())); }...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
package lab12; p public class ComboLock { int lockerId; String combination; S //default and overloaded constructors public ComboLock() { lockerId = 000000; combination = "--------"; } public ComboLock (int iD, String combo) { lockerId = iD; combination = combo; } //accessor methods public int getId() { return lockerId; } public String getCombination() { return combination; } //mutator methods / public void setId(int anId) { lockerId=anId;} l public void setCombination(String aCombo) { combination=aCombo; } //equals method public boolean equals(ComboLock theLocker) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (combination==theLocker.getCombination())); } public String toString() { return "Locker ID: "+lockerId+"\tCombination: "+combination; } public int compareTo(ComboLock aCL) { int flag=0; if(aCL.getId()<lockerId) flag = -1; else if(aCL.getId()>lockerId) flag = 1; else if(aCL.getId()==lockerId && aCL.getCombination().equals(combination)) flag = 0; else if(aCL.getId()==lockerId && aCL.getCombination().compareTo(combination)>0) flag = 1; else flag = 1; return flag; r } }...
View Full Document

Page1 / 2

ComboLock - (combination==theLocker.getCombination())); }...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online