public boolean isCompatibleWith ( DeweyNumber other ) { if ( length ( ) > other . length ( ) ) { // prefix case for ( int i = 0 ; i < other . length ( ) ; i ++ ) { if ( other . deweyNumber [ i ] != deweyNumber [ i ] ) { return false ; } } return true ; } else if ( length ( ) == other . length ( ) ) { // check init digits for equality int lastIndex = length ( ) - 1 ; for ( int i = 0 ; i < lastIndex ; i ++ ) { if ( other . deweyNumber [ i ] != deweyNumber [ i ] ) { return false ; } } // check that the last digit is greater or equal return deweyNumber [ lastIndex ] >= other . deweyNumber [ lastIndex ] ; } else { return false ; } }
Checks whether this dewey number is compatible to the other dewey number .