1: @author Frank M. Carrano, Timothy M. Henry 2: @version 5.0 3: public boolean add(T newEntry) 4: { 5: if (integrityOK) 6: { 7: boolean result = true; 8: if (isArrayFull()) 9: { 10: result = false; 11: } 12: else 13: { // Assertion: result is true here 14: bag[numberOfEntries] = newEntry; 15: numberOfEntries++; 16: } // end if 18: return result; 19: } 20: else 21: throw new SecurityException("ArrayBag object is corrupt."); 22: } // end add 23: //================================ 24: // Throws an exception if this object is not initialized. 25: private void checkIntegrity() 26: { 27: if (!integrityOK) 28: throw new SecurityException("ArrayBag object is corrupt."); 29: } // end checkIntegrity 31: public boolean add(T newEntry) 32: { 33: checkIntegrity(); 34: boolean result = true; 35: if (isArrayFull()) 36: { 37: result = false; 38: } 39: else 40: { // Assertion: result is true here 41: bag[numberOfEntries] = newEntry; 42: numberOfEntries++; 43: } // end if 45: return result; 46: } // end add