Purpose: This homework has three parts, with the goal of further practicing loops and conditionals, as well as analyzing and describing systems. As we have a midterm this week we are not introducing any new material on this homework assignment and the due date will be pushed out two days. This will not be a Pairs Programming project.
Turn-in and due date: Please read and follow the turn-in instructions carefully.
·
Parts 1 and 3 require Java source code
files to be turned in using the
web turn-in form, with the details listed below. The due date for
electronic turn-in is Thursday May 1 at
· The turn-in for part 2 is a diagram that should be handed in on paper. The due date is Friday May 2 at the beginning of lecture.
· We have added a self-assessment field to the web turn-in form. This field is for you to write a short message to your TA, indicating
o (Required) For each of the three parts, indicate to what extent you feel you completed it successfully. If you finished everything and it worked, you can just say so in a couple of words. If something does not work or is incomplete, indicate briefly what that is.
o (Optional) How well you managed your time to complete the assignment by the due date
o (Optional) other notes on the assignment you want to bring to your TA’s attention.
· This time we want you to be sure to print the receipt returned to you by the web form. The due date for the receipts is Friday May 2 at the beginning of lecture. Staple the sheets together, please, and make sure you include the diagram for part 2.
Time: The programming parts
should take 2-4 hours if you are already somewhat comfortable with loops and
conditionals, otherwise probably more. Don’t go near the computer until
you have a firm idea what you want to do!
1 – The Paper Street Soap Company, Cont'd
Purpose: Practicing loops
and conditionals.
Procedure: Complete the soap-wrapper machine problem assigned as part
of homework 2.
· Implement the cut method of the Paper class
· Implement the wrap method of the Wrapper class
· Test both method implementations using a harness. You can come up with your own scheme for testing, or follow the suggestions given as hints, below.
We’re providing you with new Paper.java, Soap.java, Wrapper.java and Harness.java files. The Harness class implements the paper and soap tests you wrote for homework 2 and also has placeholder methods for testing the cut and wrap methods. You must place your code there, so that we can call it from our test harness during grading! However, you are free to use your own solution to homework 2 instead of our Paper, Soap and Wrapper classes if you like.
Turn-in: Turn in Paper.java, Soap.java, Wrapper.java and Harness.java using the web turn-in form.
Hints: This problem was first described on the homework 2 web page.
· The details of cut and wrap are in the comments for the Paper code and the Wrapper code.
· The Harness class provided with this homework replaces the old harness that was alternatively called SoapPaperHarness and PaperSoapHarness.
· The goal of testing is to make sure the cut and wrap methods work perfectly. Your first concern is to design a test for each path through the code. Your second concern is to extend the tests to run the paths with different parameters. If you think you may not be able to test every path completely, then you must prioritize carefully – it is most important to test the commonly taken paths.
· Suggestion for testing cut: As in the tests for homework 2, generate all pieces of paper with dimensions in the range 0.5 to 20 in increments of 0.25. For each paper size, test all combinations of cuts using the following parameter values: dimension 1 (of the cut) equal to the paper length, slightly less than the paper length, and slightly greater than the paper length; equal to the paper width, slighty less than the paper width, and slightly greater than the paper width; do the same with dimension 2 (of the cut) and test all combinations together. For each combination, you know in advance whether the cut should succeed or fail! From that expectation, you can determine if the cut method returns the correct value. Incorporate that knowledge into your test code, so you can be sure that a test only fails when your code does not operate correctly. If the test fails, give a descriptive error message and continue. After running all tests, print the number of tests which succeed and the number which fail.
· Suggestion for testing wrap: Make sure to first get the cut tests working. Test wrap by creating all of the same cut test situations as described above. For each cut situation, generate and test two Soap objects: one which has dimensions which you know should cause wrap to succeed, and one with dimensions that you know will fail. Print the total numbers of successes and failures.
2 – Analysis and Decription
Purpose: Practice reading and describing a program.
Procedure: With the Homework 3 test harness, the Paper Street Soap Company project begins to get sizable. Note that the java file Harness.java actually contains several classes (review textbook chapter 3), and of course there are the Paper, Soap, and Wrapper classes. Your task is to produce a one-page graphical summary description of the system, following the steps below.
· For each class in the system, draw a rectangle and label it with the class name. Inside the rectangle, list the name of the methods of the class.
· If a method of one class (say, class A) calls a method of another class (class B), draw an arrow from the class A rectangle to the class B rectangle, and label the arrow with the method name. If there is more than one such method call, draw a separate arrow for each one. [If a method of A calls another method within A, do not draw an arrow.]
The diagram should be based on your actual, final programming solution to the problem – not on our sample solution or starter code. For purposes of the diagram, the two might similar or identical, so you could start working on this part quite early instead of waiting until finished with part 1. In fact it may be helpful to do as much of part 2 as you can during your preparation for part 1.
That’s it! You can do this freehand, as long as you do it neatly. Please (please pretty please) don’t lose time making it look overly beautiful using a drawing or graphics program. The information is more important than the presentation.
Turn-in: Staple your diagram to the other paperwork of this homework (the printed turn-in form) and hand it all in together. Please put your name and section on the diagram in case it gets separated from the rest.
3 – ASCII Art
Purpose: Practicing loops and conditionals.
You should write code to draw a letter V, a triangle, a trapezoid, a pentagon, and a hexagon. Finally, as a bonus you can produce a six-armed star and/or an octagon., but you don’t have to.
Turn-in: Turn in your updated ASCIIArt.java using the web turn-in form.
Hints:
· The figures only involve horizontal, vertical and true diagonal lines. True diagonal means that adjacent glyphs (like * or #, whatever you like best) are separated by one vertical line and one horizontal letter space. In other words, true diagonal lines have a 45 degree angle from the horizontal.
· Trigonometry might be the first thing that pops into your mind as you look at the ASCII art. You don’t need any trigonometry for figures that involve only horizontal, vertical and 45 degree diagonal lines.