Topical Information

This project will help you show your mastery of dynamic arrays, classes, and libraries. (This time it is a dynamic array as a member of a class.)

Program Information

Somewhere on the net, you find a lovely little class designed to help manage a list of temperature values. You think it could be a decent basis for more general purposes, so you download it and begin your enhancements. Here are the links, in case you forgot to bookmark them (*grin*):

First you'll need to remove all specific references to 'temperature' to make it a generic list of double data. This may require changes to identifiers, strings, etc. in various places.

Next add a method called get_last with no input to return [a copy of] the last item currently in the list. (Note that this will not change the list's contents...)

Now add a method called delete_last. It will remove the last item from the list. It can be a pure void function — no inputs and no output. (But this one, does change the list's contents! In particular, don't forget to update the size member variable...oh, that's how you remove it, isn't it? *silly Jason*)

If get_last is called by an empty list object, you may return 0.0 or NaN. If delete_last is called by an empty list object, you may simply ignore the attempt.

As a final upgrade from the temperature list, you decide you should make the list member variable dynamic instead of 'static'. You'll need to pass the number of items to be in the list to the constructor and an extra member variable to track the size. (I'd rename the current member variable something like physical_size and call this new one logical_size, but any reasonable pair of names will do...)

Remember where nullptr checks should be placed. Don't forget your destructor! (And with that, don't forget your copy constructor and your operator=...)


Place your class in its own library. Make a driver program capable of thoroughly testing its capabilities.

Other libraries may also be used for collections of functions.

Handing it in...

You'll need to run your script. Don't forget to execute your program as many times as you need to show a good sample of testing your program! Finally, if you want/need corrections, go to your favorite email and send me the PDF with a proper subject.

This assignment is (Level 3.5).

Options

You may choose to alter your program from above to add any of the following (bulleted) options. You won't be handing in a separate program (unless specifically told to do so!). You will simply change the program you already have to adhere to the new specifications below. This change is considered significant enough to increase your level as stated below.

Again: do NOT create/hand-in multiple programs! Simply altering the program you have already written is enough to increase its level by the amount specified in the option you choose...

Memory Management Options

For all of the next four options, a doubling scheme is strongly recommended for the growth algorithm itself. Toward this end, if the space requested by a programmer outside the class — should you do that option — were not a power of two, you should make it the next higher power of two to keep things exactly doubled.

General Design Options

The remaining options are on other aspects to clean up the design and make the resulting class even more reusable.


Note: This project is adapted from ones given in textbooks by Walter Savitch.


Last modified 01/07/2023 22:15:38.

It is now 3/15/2025, 7:07:22 AM.

Date you last viewed this page: That's for you to know and ...well, that's for you to know.

© 1993-2025  Jason James   (email — craie@acm.org — for permissions &/or details)