Source of 2.10.java


  1: @author Frank M. Carrano, Timothy M. Henry
  2: @version 5.0
  3:         /** Adds a new entry to this bag.
  4:             @param newEntry  the object to be added as a new entry.
  5:             @return  True if the addition is successful, or false if not. */
  6:         public boolean add(T newEntry) 
  7:         {
  8:                 boolean result = true;
  9:                 if (isArrayFull())
 10:                 {
 11:                         result = false;
 12:                 }
 13:                 else
 14:                 {  // Assertion: result is true here
 15:                         bag[numberOfEntries] = newEntry;
 16:                         numberOfEntries++;
 17:                 } // end if
 18:                 
 19:                 return result;
 20:         } // end add