Dale - Computer Science Illuminated 310

Dale - Computer Science Illuminated 310 - an item must...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Generic data type (class) A data type (or class) in which the oper- ations are defined but the type or class of the objects being manipu- lated is not 9.3 Lists 283 Notice in this CRC card that we said that the list collaborates with Item- Class . We don’t know what it is, but because items are being put on the list, the list must collaborate with the class of which the items are objects. We are writing this CRC card for a generic list. A generic data type (or class ) is one in which the operations are specified but the type or class of the objects being manipulated is not. The responsibility algorithms are quite straightforward. Initializing a list is equivalent to setting the length to zero. The act of inserting and deleting
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: an item must increment and decrement the length, respectively. As we write the algorithms, we continue to put abstract steps in blue. The steps that we outlined in the previous section we put in red to remind you that they are different in each implementation. Insert(item) Find where the item belongs Put the item there Increment length Initialize Set length to zero Class Name: Host Superclass: Subclasses: /esPrnsoSodotoes Collaborations inotovdoae otsedI inse,t LoteGu Redete LoteGu p,ont (nr)HenDtc ,etl,ns onteDe, z z z iteGfdvss iteGfdvss iteGfdvss...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online