247: return;
248: }
249: pCurrent = pNext;
250: }
251: }
252:
253: class PartsCatalog : private PartsList
254: {
255: public:
256: void Insert(Part *);
257: int Exists(int PartNumber);
258: Part * Get(int PartNumber);
259: operator+(const PartsCatalog &);
260: void ShowAll() { Iterate(Part::Display); }
261: private:
262: };
263:
264: void PartsCatalog::Insert(Part * newPart)
265: {
266: int partNumber = newPart->GetPartNumber();
267: int offset;
268:
269: if (!Find(offset, partNumber))
270: {
271: PartsList::Insert(newPart);
272: }
273: else
274: {
275: cout << partNumber << “ was the “;
276: switch (offset)
277: {
278: case 0: cout << “first “; break;
279: case 1: cout << “second “; break;
280: case 2: cout << “third “; break;
281: default: cout << offset+1 << “th “;
282: }
283: cout << “entry. Rejected!” << endl;
284: }
285: }
286:
287: int PartsCatalog::Exists(int PartNumber)
288: {
289: int offset;
290: Find(offset,PartNumber);
291: return offset;
292: }
293:
294: Part * PartsCatalog::Get(int PartNumber)
295: {
296: int offset;
568 Day 16
LISTING16.6 Continued