Educational Objectives: After completing this assignment the student should have the following knowledge, ability, and skills:
Operational Objectives: Implement and test the function templates Mean, Median, SelectionSort, and Swap.
Deliverables: Two files: stats.t and log.txt
build 10 test executables [1 pt each]: xx 40 tests [1 point each]: stattestA.x data1, data2, data3, data4 x stattestB.x data1, data2, data3, data4 x stattestC.x data1, data2, data3, data4 x stattestD.x data1, data2, data3, data4 x stattestE.x data1, data2, data3, data4 x stattestF.x data1, data2, data3, data4 x stattestG.x data1, data2, data3, data4 x stattestH.x data1, data2, data3, data4 x stattestI.x data1, data2, data3, data4 x stattestJ.x data1, data2, data3, data4 x total for tests [0..40]: xx log.txt [-20..0]]: ( x) project specs [-20..0]]: ( x) code quality [-20..0]]: ( x) dated submission deduction [2 pts per]: ( x) --- total [0..50]: xx Notes: 1. input files may vary over time and from those distributed. 2. selection of 10 tests may vary among the 19 choices Code quality includes: - conformance to assignment requirements and specifications - conformance to coding standards [see course organizer] - engineering and design, including appropriateness of name choices - readability
Background: See lecture notes Chapter 12. Templates.
Copy the following files from the course library:
proj6/stattest.cpp # client program testing Stats Templates proj6/makefile # builds stattest1.x, ... , stattest19.x proj6/deliverables.sh # submission configuration file scripts/submit.sh # submission script
Begin a log file named log.txt. This should be an ascii text file in cop3330/proj6 with the following header:
log.txt # log file for stats project <date file created> <your name> <your CS username>
This file should document all work done by date and time, including all testing and test results.
Create the file stats.t defining and implementing function templates for Mean, Median, SelectionSort, and Swap. Be sure to make log entries for all work.
READ the test program LIB/stattest.cpp. Note that stattest.cpp is set up so that you can choose any one of 19 different numerical types by uncommenting one of 19 possible typedef statements defining NumberType. Start your testing by creating 19 different tests stattest1.cpp, ... , stattest19.cpp, where stattestX.cpp uses the number type X.
This is a good exercise in using basic unix commands and Emacs. Do this work yourself, on linprog. Be sure to keep your log up to date.
READ the supplied LIB/makefile. Note that makefile is set up so that you can
Test your implementation using the supplied client program stattest.cpp. There should be 19 versions of stattest.cpp, one for each numerical type listed in the program header documentation, named as in the distributed makefile. Again be sure to make log entries appropriately.
Turn in the files stats.t and log.txt. using the submit script system.
Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu to submit projects. If you do not receive two confirmations, the second with the contents of your project, there has been a malfunction.
In file stats.t define and implement function templates with these prototypes:
template < typename T > long double Mean (const std::vector<T>& v); // returns mean of elements of v template < typename T > long double Median (std::vector<T>& v); // returns median of elements of v template < typename T > void SelectionSort (std::vector<T>& v); // sorts elements of v template < typename T > void Swap (T& x, T& y); // interchanges values of x and y
The behavior and semantics are similar to the non-template functions from Project 2, using vector instead of array to contain data.
Be sure your code conforms to the standards in C++ Style (available also through the Course Organizer).
Be sure that you have tested your code for syntax errors with the supplied test harness as well as your own test program, using the supplied makefile with warning flags set. All warnings should be eliminated.
Be sure that you have tested your code for both logic errors with the supplied test harness as well as your own test program.
Be sure that you have tested your code for genericity using all 19 numerical types signed char, short, int, long, int8_t, int16_t, int32_t, int64_t, unsigned char, unsigned short, unsigned int, unsigned long, uint8_t, uint16_t, uint32_t, uint64_t, float, double, long double.
The behavior required is essentially the same as that from homework 2 "Stats". Sample executables may be found in LIB/area51.
Copy LIB/proj6/runtests.sh. Read and understand it. Change permissions to 700. Create data files data1, data2, data3, data4. Execute runtests.sh. Be sure your data files are varied, so that int and float types get exercised with both even and odd sizes. If you get no errors and no differences to screen, you are in good shape.