Java Reference
In-Depth Information
identified such conditions, you should specify how your methods will behave under each one. You
should write down your decisions about how you want your methods to behave, as we have done in
the following table. Later, you can incorporate these informal descriptions into the Java comments
that document your methods.
A BSTRACT D ATA T YPE : B AG
D ATA
A finite number of objects, not necessarily distinct, in no particular order, and having the same data type
The number of objects in this collection
O PERATIONS
P SEUDOCODE
UML
D ESCRIPTION
getCurrentSize()
+getCurrentSize(): integer
Task: Reports the current number of objects
in the bag.
Input: None.
Output: The number of objects currently in
the bag.
isFull()
+isFull(): boolean
Task: Sees whether the bag is full.
Input: None.
Output: True or false according to whether
the bag is full.
isEmpty()
+isEmpty(): boolean
Task: Sees whether the bag is empty.
Input: None.
Output: True or false according to whether
the bag is empty.
add(newEntry)
+add(newEntry: T): boolean
Task: Adds a given object to the bag.
Input: newEntry is an object.
Output: True or false according to whether
the addition succeeds.
remove()
+remove(): T
Task: Removes an unspecified object from
the bag, if possible.
Input: None.
Output: Either the removed object, if the
removal was successful, or null .
 
Search WWH ::




Custom Search