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. */ 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"); } } 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 } 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!"); } 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. 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. 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. 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 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); }