CSC 171
Homework 4

Assigned Feb 18, due Feb 25

For all the programming assignments, be sure to follow the design recipe. Each problem asks you either to create a new class with some methods, or to add a new method to a class you've already written. For classes, you need to identify the names and types of the instance variables, then write each of the methods. For each method, go through the usual contract, examples, skeleton, inventory, body, test steps. I recommend writing the examples by using the tester library, as discussed in class on Feb. 11, so you can easily run all your tests and confirm that they all pass.

Be sure to choose meaningful names for methods and parameters, and watch for opportunities to re-use methods you, I, or the textbook have already written.

Also turn in a log of time spent and errors encountered in the assignment, with brief comments describing each error ("mismatched parentheses" is self-explanatory, but more complex errors might need more description). You may do this using the PSP forms, or simply by keeping track in a text file or on paper and turning it in.

What to Turn In

You should end up with several classes: Dummy, Posn, and Date, as well as a test class for each, with names like PosnTest, DateTest, etc. I recommend keeping all of these in one BlueJ project (with a name like "Homework4"); zip up the whole folder and attach it to an e-mail to me. If you've entered your time and error logs using the on-line forms, I've already got them; if not, e-mail me your log files.

Grading standards

Time and Error log:       /50
(I'm not grading on how many or how few errors you encountered, or how much time you took, only on whether you recorded them adequately.)

Programming:

Note: I won't actually grade every one of these methods, but a representative sample; the rest are for practice. If I were to grade them all, the points would look something like this:

Class/method name Contract (for methods) Examples (for methods) Skeleton and
inventory (for methods) or
variable list (for classes)
Class/Method definition
smallestOf3 /5 /5 /5 /10
aboveDiagonal on Posns /5 /5 /5 /10
same on Posns /5 /5 /5 /10
region on Posns /5 /5 /5 /10
count4votes /5 /5 /5 /10
whoWon /5 /5 /5 /10
whoWon4votes /5 /5 /5 /10
cardRefund /5 /5 /5 /10
legal on Dates /5 /5 /5 /10
same on Dates /5 /5 /5 /10
monthName /5 /5 /5 /10
improved toString on Dates /5 /5 /5 /10
XC: change dayInYear to handle month lengths /5 /5 /5 /10
XC: change dayInYear to handle leap years /5 /5 /5 /10
XC: change daysLater to handle month lengths /5 /5 /5 /10

General skills:

Following directions /10
Writing contracts from word problems /10
Choosing examples /10
Names, white space, indentation, general readability /10
Coding /10
Code re-use and method composition /10

Total:         depends on how many methods and classes I actually grade


Last modified:
Stephen Bloch / sbloch@adelphi.edu