1. /** Gets one of two previously stored Strings from Lockbox, based on password match. If guess is the same as the stored password, the treasure string is returned, otherwise the garbage string. @param guess the string to check against the password @return treasure or garbage strings, based on the guess matching the password. */ Rubric: Correct use of @param and @return syntax: 5 points Missing one: 3 points Extra return: 2 points Correctly describes functionality of method: 5 points Partial description method functionality, of some merit: 2 points You may also lose a single point for something like a missing /** at start. You should also start with an uppercase letter, and have a "." after the first sentence. 2. public class CashRegisterTester { public static void main(String[] args) { CashRegister reg = new CashRegister(); //This line was added. reg.addItem(1.5); //This line was added. reg.addItem(3); //This line was added. reg.addItem(5); //This line was added. int items = reg.getCount(); //This line was added. System.out.println(items); System.out.println("Expected: 3"); double change = reg.giveChange(10); //This line was added. System.out.println(change); System.out.println("Expected: 0.50"); } } Rubric: Syntactically correct invocation of the constructor: 2 points Adds 3 items: 3 points. Call to getCount(): 2 points Calls giveChange(val) with val .5 above item cost: 3 points Calls giveChange(val) with some other cost: 1 point 3. public void bet(double wager) { if(wager > funds) return; //This line was added double random = Math.random(); // A random floating-point value between 0 and 1 if (random < 0.5) funds = funds + wager; // The gambler won else funds = funds - wager; // The gambler lost } Rubric: Has if ( ) statement: 2 points. tests (wager <= funds): 4 points tests (wager < funds): 2 points Does original code when the comparison holds: 4 points Has okay syntax, but backwards logic: 1 point The above applies whether or not they used an intitial comparison with a return, or nested if, or compound conditionals. 4. public void grant(String wish) { if (grantedWishes < TOTAL_WISHES) { System.out.println("Your wish (" + wish + ") is my command!"); grantedWishes++; } else System.out.println("I smite thee for greed!"); } Increments grantedWishes: 4 points Adds the increment into a block statement: 4 points Block statement set up, but no grantedWishes in it: 2 points Else clause still working: 2 points Changes conditional to <=: -3 points (but can't go below 0) 5. a) int speed b) No methods should be added. c) The constructor should have an int speed parameter for setting speed. The move method should be changed to change the position by the speed, instead of 1. Rubric: Instance field int speed: 2 points No methods added: 2 points Constructor modified: 3 points move changed: 3 points Alternative 1: a) none b) No methods added. c) The move method should have an int speed parameter added to it. It should then change the position by the speed, instead of 1. No instance field added: 1 points No methods added: 2 points Speed parameter added: 3 points move method change: 3 points No other changes: 1 point (taken away when other changes are proposed) Alternative 2: a) int speed b) A void setSpeed(int newSpeed) method should be added to set the speed. c) The move should be changed to change the position by the speed, instead of one. The constructor should also probably set a default speed, or take a speed parameter, but since 0 is a possible default, I won't require this. Instance field int speed: 2 points setSpeed added: 3 points move changed: 3 points No other changes: 2 points (taken away when other changes are proposed) 6. I give the answer below, broken into separate method calls, with the values staggered by time even within one method call. After that, I give the simplified answer which is also acceptable. Robot turnRight moveForward x 0 1 y 0 0 dx 0 1 dy -1 0 newDx 1 X A simplified, but also acceptable answer: x 0 1 y 0 0 dx 0 1 dy -1 0 newDx 1 X Rubric: Correct values for each of x, y, dx, dy: 8 points Correct values, but with 3 values for each (values after each method call instead of after each assignment): 6 points (001, 000, 011, -100). Correct usage of X and values in newDx: 2 points Some indication of scope for newDx: 1 point 7. public void paintComponent(Graphics g) { // Recover Graphics2D Graphics2D g2 = (Graphics2D) g; // Construct and draw one note base Ellipse2D.Double base = new Ellipse2D.Double(10, 30, 10, 10); g2.fill(base); // Consruct and draw the stem Line2D.Double stem = new Line2D.Double(19, 10, 19, 35); g2.draw(stem); // Construct and draw 2nd note base base = new Ellipse2D.Double(30, 30, 10, 10); g2.fill(base); // Consruct and draw the 2nd stem stem = new Line2D.Double(39, 10, 39, 35); g2.draw(stem); // Construct and draw the top bar Rectangle bar = new Rectangle(19, 10, 20, 5); g2.fill(bar); } Rubric: Syntactically correct code for making, drawing 2nd circle and stem: 1 point Circle solid and Line Vertical: 1 point Line attached: 1 points Same height as original: 2 Syntactically correct code for making, drawing rectangle to attach: 2 Used a line: 1 Rectangle attached correctly: 2 Line attached correctly: 1 Note in window and spacing: 1 point