Lab #4: Project #1 checkpoints Get the various points in this lab checked off by your lab on the week of 30 September. It would be good, of course, to have them done the FIRST week! Indeed, you will probably want to have done a good deal of the implementation work prior to coming into lab for checkoffs. In order to do the steps below, you need to have copied over the ~cs61b/hw/proj1 files. In what follows, I assume you are in a directory that contains the Project#1 files, possibly already modified by you. 1. Fill in User-Manual (I suggest, of course, that you do this OUTSIDE the lab and just have it ready for check-off). 2. Remove any .class files in your project by issuing a 'gmake clean'. command. In Emacs, use the compile command (C-x C-e or the menu) to execute 'gmake check'. The first thing this command does should be to try to recompile your files (if it doesn't, you've broken something; unbreak it and try this step again). Examine Project #1 Makefile. What is it in this Makefile cause gmake to recompile your files? Assuming your files compile, 'gmake check' will then try to run the two test cases, which should fail (unless you've already implemented this part of the project!) Actually, 'gmake check' goes into an infinite loop; can you see why? (Deleting the *compilation* buffer will stop the loop). Try fixing this problem (you just have to add one line to pcalc.java). Do another 'gmake check'. What do the messages you get in response to this mean (e.g., the lines that start with "<", or things like "1,2d0"? What Unix command produced those lines? NOTE: I said "In Emacs", and I meant it. If you are NOT using Emacs commands to run all compilations and test scripts, and are instead issuing commands in a shell, you are SEVERELY handicapping yourself in the long run. Emacs, properly used, or (for those of you at home) an IDE (Integrated Development Environment) offering the same compilation-control features prevents errors, keeps your screen uncluttered, and speeds up your interactions considerably. And always remember: I can ask ANYTHING on an exam! 3. How does the Makefile use test-filter? Why do you suppose I included it? 4. On the basis of the project specification and your User-Manual, devise a set of test cases in the style demonstrated by the test*.* files provided for Project #1 and update your Makefile to run them. Start with a file of simple tests that test only one- term polynomials (like x, 3, -3, x^2, etc); in fact, you might just start with one-factor polynomials. Then try multi-term polynomials without parentheses. Then throw in parentheses. file using just numbers, arithmetic operations and =. Use "#" comments in both of these test files to describe what they're supposed to test (and incidentally to test the # is working!). Now try some simple DEF's, and so forth. The idea is to systematically test possible inputs. Again, this is something you can do outside lab and have checked off. 5. Use the commands prcs populate prcs checkin in your Project 1 directory to add your test cases to the repository. The steps above do NOT require you to implement any part of the pcalc program; your tests ought to work on anyone else's project as well, for example. Now we turn to implementation. 6. Choose a representation for Polynomials, and define the necessary fields (which should be private) constructors, and factory methods (you may add others later, but make a reasoned guess based on what the class has to do). Feel free to use types from the Java Collection classes, like ArrayList and LinkedList in package java.util, if you find a use for them. You may want (but don't have to) to introduce additional classes to represent Terms and Factors, together with their constructors, fields, and methods (I'm asking for representation at the moment; feel free to put off actually implementing any methods). Put a description of the representation (including all classes you added) in the INTERNALS document. That is, provide a clear description there of how you propose to represent an arbitrary polynomial. Bear in mind that you only have to represent polynomials in CANONICAL FORM; that saves you from having to invent a representation for substitutions, parenthesized expressions, etc. The idea is to choose a representation that you know how to manipulate. Can you figure out how to add and subtract two polynomials, represented as you have done? How to multiply? How to substitute for variables? Get what you have written to compile (with dummy bodies for new methods if any), and then use the commands prcs populate prcs checkin (You only need to populate if you added more files). 7. Choose a representation for Defns, which stores definitions of Polynomials. This should be very easy, since there are at most 26 definitions, and they are numbered consecutively 'A', 'B', .... In fact, you ought to be able to fill in the methods almost immediately. Add a description to INTERNALS. As usual, be sure to 'prcs checkin'. 8. Fill in the parseExpr, parseTerm, and parseFactor methods to handle the case of expressions consisting of a single term, consisting of a single factor---either an integer or a simple variable. Call the Polynomial.constant and Polynomial.var methods to produce the proper Polynomials (even if they don't quite work yet!). 9. Fill in enough of the main method to handle the 'expression;' case. 10. Implement enough of algebra.Polynomial to get .constant and .var working, and also toString() for the Polynomials they produce. [And, you HAVE been doing 'prcs checkin' all this time, right?] [Together, items 6, 7, 8, 9, and 10 give you a sort of "hello, world" calculator---one that's just starting to work.] 11. Have your TA check off that you have substantially completed the points here (there is still plenty to do, of course).