CPS08: Lab2, Compiling, Linking, Mosaic As part of lab 1, you should have created a directory called cps08. Change into that directory using the cd command and create another directory called lab2 using the mkdir command. Change into the lab2 directory. If you did this correctly, when you type pwd you should see a long path name that ends with /cps08/lab2. You need to copy some files to do this lab. The cp command is used for copying files on Unix systems. Type the following command to copy files for the lab (don't forget the trailing period, or dot): . This command will copy all the files in the directory ~ola/cps08/lab2 into your cps08/lab2/ directory. If you type ls you should see the following files: Makefile, parts.cc and winner.cc. For each of the programming problems that follow, you should use the style rules discussed in class, which includes meaningful variable names, indentation, and comments at the top of the file and for each function. To compile these programs, you will NOT use the g++ command explicitly, but rather implicitly. The file Makefile will make it easier to use the g++ command. To compile the program called winner.cc, type make winner. To compile any program named foo.cc into an executable foo you can type make foo. This will automatically use the g++ command and link to libraries that you'll need (including libraries from the book and the math library). If your program compiles correctly, the executable file called winner will be created. Then you can type winner to run your program. Before beginning you should run emacs. To do this type emacs &. The ampersand & runs emacs in background so that you can still type in the xterm from which emacs was invoked. Problems 1. The program winner.cc should produce the following output. Congratulations Coach K Your back is better! This program has both syntax errors (found by the compiler) and a logic error (not found by the compiler). You can read over the program looking for mistakes and edit the file to correct them or you can rely on the compiler to catch syntax errors for you. Compile this program by typing M-x c (that's escape X c in emacs) then type make winner in the mini-buffer. If you didn't copy the .emacs file in lab1 you may need to type M-x compile and then make winner. Correct all syntax and logic errors so the program runs correctly. The parts.cc file contains the face drawing program from the book. You should add two functions to the program. These functions can draw a mustache, a beard, a nose, glasses, or anything else you feel like creating. After adding two functions, modify the main function to draw a new face that uses both of your functions. For example, your face might look something like the following (feel free to design your own glasses and beards): |||||||||||||||| | | | ____ ____ | |--| o |-| o|--| | ---- ---- | _| |_ |_ _| | |______| | | | ||| ||| ||| ||| \\\/// CAUTION: The \ (backslash) character is a special character . To print one backslash, you must put two backslashes inside of the double quotes (this is called an escape sequence. For example, to print three backslashes, you must put six inside the double quotes. For cout << "\\\\\\" << endl; the output will be: \\\ To turn in programs: When both of your programs for problems 1 and 2 compile and produce the correct output, you can turn them in by typing: submit08 lab2 winner.cc parts.cc README The README file should include your name, how long you worked on the program, and anyone you received significant help from. You should receive a message telling you that the programs were submitted correctly. Mosaic is a networked tool for retrieving information. Start Mosaic by either clicking on the Mosaic box at the top of your screen or typing Mosaic at a UNIX prompt. Mosaic starts with an information page on Duke University. Click on a topic to receive more information on it, and a new page will appear. Use the Back button at the bottom of the window to retrace your steps. Using Mosaic, answer the following questions. 1. List two things that Prof. Astrachan divides his time between including his preferred form of exercise. (Hint: Prof. Astrachan is a faculty member in the Computer Science Department). 2. List a research paper about theorem-proving with Meteor written by Prof. Astrachan . 3. If you follow the links to CPS08, you'll see handouts for class are listed on this Mosaic Page. By clicking on any one of them, they will automatically be displayed on your screen. If you want a copy, you can choose the file button, and then the print button. You do not need to print anything for this assignment. 4. In what year was Duke founded? To find the answer to this question you can go to the Duke University page from Prof. Astrachan's page. From there go to ``Duke University at a Glance'' and then to ``history of Duke''. 5. Does Jeff Vitter have a mustache? (Hint: Jeff Vitter is chair of the Computer Science Department at Duke. His picture is on his Home Page.) That's it for lab 2. Make sure you used the submit command to turn in the programs for problems 1 and 2, and that you get checked off by a TA for completing the lab.