i Have the following code but i am confused how i throw the InvalidLockCombinationException. This
exception (which should not have any methods) will indicate that an attempt to assign a
combination to a lock failed (thus making the combination invalid for that lock). If the combination is invalid
(if not all its numbers are in the dial) then the constructor should throw a new
InvalidLockCombinationException. By throwing this exception we can avoid creating locks with
invalid combinations (which in real life will be defective). All locks are open when created this is what i have so far. Any help would be appreciated on how to get the exception working.
public class Lock{
public Combination correct;
public int upperLimit;
public boolean isOpen;
public Lock(int aLimit, Combination aCombo) throws InvalidLockCombinationException(){
correct = aCombo;
upperLimit = aLimit;
isOpen=true;
int[] comboHolder = new int[3];
comboHolder = aCombo.getNumbers();
for(int i=0; i<comboHolder.length;i++){
if(comboHolder[i]<0 || comboHolder[i]>upperLimit){
throw InvalidLockCombinationException;
}
}
}
}