CS1411 - Introduction to Programming Principles I

Programming / Lab Assignment 8

Warning: There will be points deducted if the assignmnent is not submitted in the correct format. Please see the submission guidelines!

Second warning: This is the early post of this assignment. The specifics might change until Tuesday, Nov 2nd. However, this should be mostly it.

Templatisizing, Exceptionizing and using the smart integer array

Please note: You may use this reference implementation of smartArray.cpp (shamelessly stolen from a student) or your own.

Overview

In this assignment you will extend the smartArray from the last assignment and use it to read numbers in from a file

Program flow

Your program will ask for a filename. The file should only contain numbers that can be represented with the double type. It will read in that file until the end, storing all numbers in a smartArray. Once the file is read completely and closed, it will call printArray to print out the array on screen. It will also test the exceptions (see below).

Implementation details

To use the type double in your smartArray, change your smartArray. Instead of using int as a datatype, make it a template. Please note: Only change the data to int, not any counters!

Also please note: Templates only work as expected, if their decaration and instantiation are in the same part of the compiled code. This means: Don't use seperate compilation in this case, you may use just one big main.cpp file.

Instead of using assertions in elementAt and setElementAt use exceptions. Throw exceptions with the value of the invalid index number. Test the exception handling by trying to access an invalid element, and catching the exception in your main program, and printing a statement like index -1 is out of range.

Your programs should include comments whith you name, testnumber, etc. in the top. See also the Submission guidelines

The assignment is due Friday Nov 5, 6pm. You have to submit it electronically as stated in the submission guidelines!

Lost? See the Help! page.