CSE 109 Programming Assignment #1 Due: 9 PM Thursday 14 February 2008 (Late collections 9 PM Saturday 16 February, 9 PM Sunday 17 February) This assignment is an exercise in developing class Scan that provides the functionality for reading a text file and faithfully writing out the same file line by line, except for removing any occurrences of certain characters and except for removing comments that follow a special "comment character" on a line. The "comment character" is removed as well. The characters to be ignored are specified by the call to the constructor. The "special comment" charcters is '#'. Thus, when '#' is encountered everything up to the end of the line should be ignored as a comment. Provide the declaration of the class Scan in the file scan.h and provide the definitions (code) for class Scan in the file scan.cc. In /proj/csc109/p1 I have stored the file p1.cc, which is a driver for testing the class Scan. I have also stored a sample input file, /proj/csc109/p1/p1.dat. You should copy the files p1.cc and p1.dat into your directory cse109.081/p1. Create a Makefile for compiling p1. DO NOT CHANGE THE CODE OF p1.cc AT ALL (BUT IT IS VERY IMPORTANT THAT YOU DO ADD DOCUMENTATION). I REPEAT, DO NOT CHANGE THE PROGRAM CODE IN ANY WAY OTHER THAN TO ADD DOCUMENTATION (name, assignment, program purpose, etc.,). OTHERWISE YOU WILL LOSE AT LEAST 20 PTS. I will test your class Scan by using the command "make clean" to discard all .o files (where you should implement "clean" in your Makefile), by replacing your p1.cc with the the file /proj/csc109/p1/p1.cc, by using your Makefile to compile p1.cc, and then by running the resulting executable file p1 with various versions of the file p1.dat. IT IS IMPORTANT THAT YOU COMPILE ALL YOUR .cc FILES WITH THE -Werror -Wall OPTIONS (E.G., g++ -c -Werror -Wall p1.cc). When you are ready to submit your work, create the file "DONE" by executing the command "touch DONE". Notes: 1. All your files should have good documentation. Each file, inlcuding p1, should have identifying information at the top, e.g., your name, the course, the assignment number. Your class should be documented with comments at the top which explain the class and its purpose. The role of each data member should be explained. Each member function should be explained (e.g., by stating pre- and post-conditions and by stating the overall algorithm). Hard to understand sections of code should be explained. 2. The files are stored in /proj/csc109/p1. The documentation in p1.cc indicates the expected output. 3. When you display the file p1.dat on the screen it looks really weird, because I have sprinkled the character '\r' throughout. That character is the carriage return (better called the cursor return) without the corresponding linefeed, so the display continues at the beginning of the same line, overwriting the text that had been previously displayed there. The character '\r' usually does not occur in unix systems, but will occur in files imported from Windows. You can see this character, indicated by ^M, by looking at the file in emacs or by typing the command more p1.dat. 4. At the bottom of p1.cc, in a comment, is a copy of the contents of the input file and the expected output. When p1.cc is displayed on the screen, the expected output is hard to read because of the \r's, which are not ignored in the last call to testScan(), thus writing over previous output on some lines. 5. The method reset() in class Scan should go back to the beginning of the input file. The follwing two istream methods (in the order given) accomplish that: clear(); //clear all (bad) input flags seekg(0); //back to the beginning of the file So, if Scanner has the instance variable istream *f; you would write f->clear(); //or (*f).clear(); f->seekg(0); //or (*f).seekg(0); IN THE SYLLABUS READ THE STATEMENT ABOUT UNFAIR COLLABORATION AND AVOID UNFAIR COLLABORATION