CPTR-142 Homework #13 - Due Monday 5/19/14


The topic of this homework is Templates. So, for program 13 modify your program 8 (lists) to be defined as a class template. You don't need to add functionality, just put it into template form. The data type for the data to be contained in the list is what will be specified via the template. Of course in the main you will need to define the data type for the object you declare and the data that will be stored in the list.

Your main needs to show functionality of the class, thus in the main declare an object that uses integers and another object that uses real numbers (i.e. floats or doubles), put some data in them, and demonstrate functionality. The reference I showed in class about templates is here: www.cplusplus.com/doc/tutorial and then under Classes(II).

For your convenience, below is a copy of the program 8 definition:
---------------------------------------------------

For program 8 finish the design of, and write the code for, a class that creates a list based on an array as we discussed in class. This class will define a list of student scores (integer values 0 to 100, i.e. percent) and have a set of functions that include, but are not limited to: You may wish to have other functions, that is ok. You need a default constructor that will create and initialize the array and possibly other variables. To denote an empty array entry we agreed to place -1 in it. I suggest a default array size of 10 items. You could create a second constructor that would allow a parameter to be passed to it for determining how large the array will be.

Write a main that will declare one or more objects, put some data into the array, get the average and display it. (You could have a display function in the class that would display the number of items and their average, but that is not required).
----------------------------------------------------


Bring a printout of your main.cpp file to class. Email the main.cpp files to me but as you do that change the name to: name_program13.cpp where name represents your last name. And between name and program13 is an underscore. I appreciate not having spaces in your file names.

Larry Aamodt PhD, PE
Professor of Engineering and Computer Science
Walla Walla University
Contact:
via email: AamoLa (at) wallawalla.edu
via phone: x2058