CSC152 2006S, Class 30: Notes on Exam 1 Admin: * Homework: Think about how to implement priority queues. * Sorry about confusion on Friday's lab. Overview: * General notes * Problem 4: Edit Distance * Problem 1: Building Fractions * Problem 2: Comparing Stuff * Problem 3: Piggy Banks /General Notes/ * Shortest mostly-correct exam: 4 pages; Longest: 41 * "n.p." means "no penalty" * Not all of you took advantage of available extra credit. * Not all of you took advantage of the grade for effort. * I care about capitalization (but did not take off, this time). + Fields, variables, methods: Begin with a lowercase letter. + Classes: Begin with uppercase letter, mixed case. + Constants: All caps. + Packages: All lowercase. * I care about indentation. * Extra work can lead to penalties as well as extra credit. * Don't print error messages in utility classes. public void myUtilityMethod() { PrintWriter pen = new PrintWriter(System.out, true); ... if (...) { pen.println("Sorry, I've noted an error."); } } DO NOT PRINT ERROR MESSAGE IN UTILITY CLASSES Programming model User \O | <-> User Interface <-> Utility methods / \ WHEN THINGS GO WRONG, THROW AN EXCEPTION /Comparing Strings/ * Some of you made this more difficult than it should have been. * I tried to give you a straightforward algorithm to translate into code. * Part of the issue was discovery: How expensive is this algorithm? * VERY * Gives an edit cost, but at a high cost * Does not tell us *how* to edit. /Fractions/ * Conceptually complicated for some: To build one fraction, you need to build others. + Possible to do without that conceptual complication, but more difficult. * Some issues with rounding up and rounding down (particularly with negative numbers). E.g., Fraction smaller = new Fraction((int) Math.round(d), 1); Use ceiling and floor. /Comparing Points/ * Most of the necessary utility code was in the reading on classes. * Many of you got the wrong metric. * Is it a good metric? Why or why not? /Piggybanks/ * Generally fine.