Interview deadline has been extended until the end of Friday, March 14. BUT, if the line is too long to finish all of the people in line Friday, then there will be NO more extensions. Those still in line at closing time Friday will receive a zero for the assignment. CSE 9B Winter 97 This is a tentative version. There may be some minor changes. Check this file from time to time for updates. Assignment 7: This is a double assignment that counts for two assignments. This is the last assignment. IMPORTANT: Read the instructions carefully. If you follow instructions, but do not finish, you may get partial credit. If you ignore the instructions your chances for partial credit are very very low. If you follow the instructions, you can start this assignment before you learn how to overload the [] operator or the assignment operator. DUE DATE: DO NOT TURN IN THIS ASSIGNMENT BEFORE THURSDAY Feb 27. Due dates: turnin program Sunday March 9 (Note that the due day is a SUNDAY. Note that there are few proctor hours on the weekend; get your help before the weekend.) Interview deadline: last week of classes Wedensday March 12 REQUIRED READING: Savitch text Chapter 11 & Appendixes 6, 7, & 8 (Note Appendixes 6 and 7 are not needed for this assignment, but may be on the final.) PROGRAMMING: This assignment is similar in character to the one in which you gave function and operator definitions for the class Rational. In this assignment you are asked to give the definitions of all member functions and all overloaded operators for a class called IntArray. Objects of the class IntArray are like ordinary arrays of integers, except for the following: 1. They are declared with round brackets, rather than square, as in IntArray a(10); 2. You can use a variable in an array declaration, as in int size = 10; IntArray(size); 3. You get an error message when an array is out of range. For example, cout << a[10]; will produce an error message because the index 10 is out of range. This is a fatal error and should end the program. similarly, any of the following will also give error messages a[11] = 42; a[-1] = 99; 4. You can use the assignment operator (=) with these arrays and it will copy all the array values. 5. You can use the operator << to output the values of these arrays. You should use a make file and should have your test program in three files: a header file, implementation file, and an application file which is a test of your class definition. We have provided you with the header file and the application (test program) file; they are in intarray.h and test_intarray.cxx. All you have to do is give the implementation file, which you should call intarray.cxx. You will ONLY TURN IN the implementation file intarray.cxx. However, you should check to see that your implementation works correctly with the other two files. You are NOT given a make file, but can easily construct one by modeling the make file for assignment 2. (You do not hand in the make file.) NOTE 1: You must use the header file, intarray.h completely unchanged, NOTE 2: You should create a make directory and make file to test your implementation, but you only turn in the implementation file intarray.cxx. Free Code! The file intarray.h has the class definition. The file test_intarray.cxx has the code for a test program to use as the application program. The file hw07.freecode has the definition of a stub for the overloaded [] operator. This version does not give error messages for out of range indexes, but will be good enough to do lots of testing. For full credit, you must replace this stub with a version that gives an error message and ends the program whenever there is an array index that is out of range. IMPORTANT NOTE ON HOW TO DO THIS: IF YOU DO THINGS IN THIS ORDER, but do not finish, you will receive partial credit. OTHERWISE, YOU WILL RECEIVE LITTLE OR NO PARTIAL CREDIT. 1. Produce a file intarray.cxx that contains the definitions of all the member functions and overloaded operators needed to run the application test_intarray.cxx just as it is, with all the /* and */ left in the file. Note you can use the definition it hw07.freecode just as it is at this stage. Unless this much compiles and runs without any errors, you will receive zero for this assignment. 2. Next you will change the definition of the overloaded [] operator (which you got from hw07.freecode) so that it gives and error message when an array is out of range. It should also end the program when it finds an array out of range. Test this by removing the /* */ around code that says it should end the program. Do these one pair of /* */ at a time. Once one works ok, put back the /* */ and test another. When you are done, restore the file test_intarray.cxx so it is in its original state with all the /* */ in it. 3. Add the definition of the overloaded << operator. Remove the /* */ around the tests for << and make sure your definition is correct. 4. Add the definition of the overloaded assignment operator (=) Remove the /* */ around the tests for = and make sure your definition is correct. 5. Add the definition of the copy constructor. Remove the /* */ around the tests for the copy constructor and make sure your definition is correct. If you get through 1-4 you will get 90% of full credit (assuming everything else is right.) REMEMBER: DO 1-6 IN THE ORDER first 1, then 2, then 3, then 4, then 5 (or as many as you can get done doing them in order.) Compiled code: The file hw07.o contains the compiled code for a program that behaves just as your implementation should behave on the test program if you use the program test_intarray.cxx just as it is. The file hw07-2.o contains the compiled code for a program that behaves just as your implementation should behave on the test program with all commented code restored (i.e., with /* and */ removed.) NB. We did not remove the /* and */ for those parts that would end the program, but did remove all the rest.