Due: Monday, Sept. 30 by 8am
Last Date to Turn in: Monday, Oct. 7 by 8am
40 points
In your cps100 directory, create a directory called assign2 using the mkdir command. Change into the assign2 directory.
In order to do this assignment, you need to copy some files using the following cp command (don't forget the trailing period, or dot):
cp ~rodger/cps100/assign2/* .
This command will copy files into your directory for you to use. If you type ls you should see the following files: Makefile, polynomial.cc, polynomial.h, and testpoly.cc.
For the programming problem that follows, you should use the style rules discussed in class, which includes meaningful variable names, indentation, and comments (pre and postconditions) at the top of the file and for each function. Also include your name, date, course, and purpose in a comment at the top of the program.
Design a class called Polynomial that can store a polynomial with real coefficients. The polynomial should be implemented using a linked list. Your polynomial should be sparse, that is, if the coefficient is zero for a particular term, then there should not be a node for that term.
Your class should have the following.
3.5 * x^7 + 4.5 * x^2 + 8
You must also write a program called testpoly.cc that shows a thorough testing of your polynomial class. It should demonstrate that every part of your class works.
In attacking this program, first design your program on paper, and come ask questions if you are stuck. When you start the implemention, don't try to type in the whole program all at once, but rather add functions one at a time, make sure they work, then add more functions. Starting early will allow you to ask more questions.
For this assignment, you are to create a C++ class for polynomials in the two files polynomial.cc and polynomial.h, a program to test the class called testpoly.cc, and a file called README. Your program should follow the style rules, using meaningful variable names, indentation, and comments that include your full name, date, and a comment with each function you write. Your program should be modular, that is, containing many functions, each with a different purpose. The README file is worth 2 points and should contain your name, date, an estimate of how long you worked on the programs, and a list of people you consulted with in doing this assignment.
A Makefile is given. It does not need to be modified. To compile your program using the Makefile, just type: make testpoly
There is no input for this program. Your program testpoly.cc should not read in any input.
Print meaningful output.
Add an additional public member function called MultByPoly.
MultByPoly(P) - multiply the polynomial by another polynomial P. Return true (1) if the multiplication was successful, 0 otherwise.
Show this function works in your testpoly.cc program.
When your programs compile and produce the correct output, create a "README" file (please use all capital letters). Include your name, section number, the date, and an estimate of how long you worked on the assignment in the "README" file. You must also include a list of names of all those people (students, prof, tas, tutor) with whom you consulted on the assignment. See the rules for collaboration in the CPS 100 syllabus.
To submit your programs electronically type:
submit100 assign2 README polynomial.cc polynomial.h testpoly.cc
You should receive a message telling you that the program was submitted correctly. If it doesn't work try typing ~rodger/bin/submit100 in place of submit100 above.