292: int PartsCatalog::Exists(int PartNumber)
293: {
294: int offset;
295: thePartsList.Find(offset,PartNumber);
296: return offset;
297: }
298:
299: Part * PartsCatalog::Get(int PartNumber)
300: {
301: int offset;
302: Part * thePart = thePartsList.Find(offset, PartNumber);
303: return thePart;
304: }
305:
306:
307: int main()
308: {
309: PartsCatalog pc;
310: Part * pPart = 0;
311: int PartNumber;
312: int value;
313: int choice = 99;
314:
315: while (choice != 0)
316: {
317: cout << “(0)Quit (1)Car (2)Plane: “;
318: cin >> choice;
319:
320: if (choice != 0)
321: {
322: cout << “New PartNumber?: “;
323: cin >> PartNumber;
324:
325: if (choice == 1)
326: {
327: cout << “Model Year?: “;
328: cin >> value;
329: pPart = new CarPart(value,PartNumber);
330: }
331: else
332: {
333: cout << “Engine Number?: “;
334: cin >> value;
335: pPart = new AirPlanePart(value,PartNumber);
336: }
337: pc.Insert(pPart);
338: }
339: }
340: pc.ShowAll();
341: return 0;
342: }
560 Day 16
LISTING16.5 continued