CSE 109 Program #0 Due 9:00 PM Thursday 7 February 2008 (Late collections: 9:00 PM 9, 10 2008) In this assignment I ask you to develop a class whose objects are meant to implement the concept of a Path. At the bottom of the page I describe the properties of a Path. In /proj/csc109/p0 I have stored the file p0.cc, which is a driver for testing the class Path. The file p0.cc also has the declarations and code for the class Point that I developed. I have stored in the file /proj/csc109/p0/p0.out the output that appeared on the screen when I ran the compiled version of p0.cc with my implementation of class Path. Further, I have stored the file 'Makefile' in /proj/csc109/p0. You should copy the files /proj/csc109/p0/p0.cc and /proj/csc109/p0/Makefile into your directory cse109.081/p0 (a directory you should create). You should do all your work in the directory cse109.081/p0. I will collect your work from there. You should add to p0.cc your declaration of class Path, as well as the definitions (code), BUT DO NOT CHANGE THE *CODE* THAT I WROTE IN p0.cc AT ALL (BUT IT IS VERY IMPORTANT THAT YOU DO ADD DOCUMENTATION). I REPEAT, DO NOT CHANGE THE CODE THAT I WROTE IN ANY WAY, but ADD DOCUMENTATION (name, assignment, program purpose, etc.,) AND YOUR OWN CODE FOR THE CLASS Path. OTHERWISE YOU WILL LOSE AT LEAST 20 PTS. I will test your class Path by using the command "make clean" to discard your executable file. Then I will compile and run your p0.cc (by executng the command 'make'). When you are ready to submit your work, create the file "DONE" by executing the command "touch DONE". Notes: 1. Both your file p0.cc and your makefile, should have good documentation. Each file 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 to understand sections of the code (definitions) should be explained. 2. I found the class Point useful in my implementation of Path. If you do not use the class Point, delete the declaration and definitions from p0.cc. 3. For neatly displaying doubles, see p528 of the text (Savitch). IN THE SYLLABUS READ THE STATEMENT ABOUT UNFAIR COLLABORATION AND AVOID UNFAIR COLLABORATION A Path is a sequence of points. In my description of a Path I indicate in parentheses the method or operator that the class Path uses to implement the given property. Examine the code in p0.cc and the expected output to clarify how the methods and operators should function. Note that the expected output is listed in a comment at the bottom of p0.cc and in p0.out. We should be able to add points to a path (+=). We should be able to determine how many points are in the path (length()). We should be able to determine how long the path is (distance()). We should be able to splice two paths together (+). We should be able to set a variable equal to a path (=). We should be able to ask whether two paths are identical (==, !=). We should be able to access individual points in the path ([]). We should be able to display the points in the path (<<). We should determine whether a path is a loop, i.e., whether the last point and the first point in the path are the same (isLoop()). Note: 4. To compute the distance(), you need to use the square root function ( double sqrt(double b) ). In p0.cc I have included , a library that has the sqrt() function. The distance for a path is the sum of the distances between consecutive points in the path. The distance between points (a,b) and (c,d) is the square root of (a-c)*(a-c)+(b-d)*(b-d).