CSC152 2005S, Class 32: Notes on Exam 1 Admin: * Exam 1 returned * Those who miss class have their exams lost in my office, perhaps permanently * Don't forget about your homework for break * Write an algorithm to keep Rolf and Elizabeth quiet * Write an algorithm to make the current east-siders loud (so moving Rolf to the east side doesn't work) * Write an algorithm to stop Sam from being so obnoxious and violent (no, a bucket of paint is not appropriate) Overview: * General issues * Particulars of problem 3 * Questions /General Issues/ * Front page: * Points for each problem 1: 2: 3: * Extra credit: Name (2 points); Time (2 points); Early (2 points) * SIGNED AND DATED! * If you didn't sign, talk to me or you get reported to CAS * Yes, you may still get reported to CAS even if you talk to me * Trimodal 1/3: Close to 100 (some fraction wrote "There is more to life ...") 1/3: Close to 80 (some wrote "There is more to life ...") 1/3: Close to 50 (but wrote "There is more to life ...") * Sam's biggest complaints: * The template and the "reference manual" (problem 1) were to be *separate* documents * You write incredibly repetitive code * Need to work on formatting and commenting if (test) { statement; } else { statement; } num = randy.nextInt(4); // If we've selected quarters as the coin to shake, and // there are no quarters, try dimes instead. if ((this.quarters == 0) && (num == 0)) num = 1; /Problem 3: Calculator/ * Goal: Write something that does simple calculations with fractions * Intended areas of testing: * Input and output * Loops * Use of our Fraction class * Modify our Fraction class * Consider use of a new Constructor with strings as a parameter Repetitive code * What's wrong with cut-and-paste programming? * Sometimes you forget to change something you should have changed * If you made a mistake in the original "chunk of code", you need to find everywhere you copied it and fix it. * If you decide to change capabilities, you need to find everywhere you copied it and change. Solution? * Write a general template and *make it a method* * Or parameterize it in different ways Note: * May actually be *less* effort (once you have the appropriate abstractions in mind) * Certainly creates shorter code!