Like last week, you'll do this lab in the UNIX environment on the blackduck computer.
Once you have your own personal copy of the "lab8" directory, you should find two files within it. One is named "sorterTest.cpp". This is the tester file (the one with main) that will use the sorter class you're about to write to sort arrays of anything, be they strings or ints or whatever. I've printed out a hard copy for you so you can study it to see what it's doing.
The second file is named "sorter.h". This is the file you will edit with pico. "sorter.h" will define the sorter class, including the implementation of all the member functions.
I have provided the private section of the class for you. It consists of one variable and one member function. The variable called list is an array of type genericType. This is the name of the type parameter you should use in this template class.
Note how I placed the findIndexOfMax function in the private section. This is done as a security measure. By making the function private, only other member functions can call it. The main function can't call it. SelectionSort used findIndexOfMax "internally" to find the next biggest item to swap with. It is only needed by the function doing the sorting, not by any other function. Since no other function needs it, we can protect it from being used unnecessarily by making it private.
g++ sorterTest.cpp -o mySorterRemember, you don't need to compile the header file. The "-o" option tells the compiler to place the finished executable into a file called mySorter. You can run it by typing
./mySorterDebug your code until it works. Don't forget that you can press Control-C while in pico to display the line number you are on. This makes compiler errors easier to find.
Don't forget to run your own tests too. Don't just depend on mine.
logoutThen use the file transfer program to transfer the two files (sorterTest.cpp and sorter.h) to your desktop. Place the files into a folder, name the folder with your name, zip them up (right click on the folder), and then upload the zip file to BlackBoard. Don't forget to print out hard copies and to include your opening comment block!
Remember, you will be graded on the correctness of your implementation, neatness, presentation, style of your program code, thoroughness of your testing, and good use of the C++ language. It's important to comment your code where appropriate and to do little things like space things properly, use readable indentation, and also to make sure the overall design and logic of the program are coherent.