CITS2200
Interface Combination


public interface Combination

Interface for a combination belonging to a combination lock.


Method Summary
 boolean equals(Combination otherCombo)
          tests whether two combinations are the same
 int getInt()
          get the combination as an integer
 String getString()
          get the combination as a String
 void setInt(int newCombo)
          set the combination using an integer
 void setString(String newCombo)
          set the combination using a string
 String toString()
          provide a string representation of this object
 

Method Detail

getInt

int getInt()
get the combination as an integer

Returns:
an integer in the range 0 - 999

getString

String getString()
get the combination as a String

Returns:
a string in the range "0" - "999"

setInt

void setInt(int newCombo)
            throws OutOfBounds
set the combination using an integer

Parameters:
newCombo - the combination represented by an integer
Throws:
OutOfBounds - if the integer is not in the range 0 to 999

setString

void setString(String newCombo)
               throws OutOfBounds,
                      NumberFormatException
set the combination using a string

Parameters:
newCombo - the combination represented by a String
Throws:
NumberFormatException - thrown by Integer.parseInt if the String cannot be parsed to an integer (you do not need to throw this in your code)
OutOfBounds - if the String represents a number not in the range 0 to 999

equals

boolean equals(Combination otherCombo)
tests whether two combinations are the same

Parameters:
otherCombo - the Combination object to compare with this one
Returns:
true if the passed combination matches this one, false otherwise

toString

String toString()
provide a string representation of this object

Overrides:
toString in class Object
Returns:
a string representation (of your choosing)