CS 1110 Introduction to Computing using Java    Spring 2010  
19972 TR 09:05 Hollister B14 Instructors: David Gries  
19974 TR 11:15 Hollister B14 Grade: letter or S/U.   Credits: 4
flue image

Breakout Questions and Answers

Below are questions asked about Breakout and our answers to them.

4. Problem: I can't get the paddle to follow the mouse. I wrote mouseMoved(MouseEvent e). Should I be calling it?

First, see whether mouseMoved is called. You can do this by putting a println statement as the first statement in it body —perhaps printing out e.

Second, we had a lecture on listening to events in a GUI. This GUI is slightly different from the awt and swing packages we used, but the principles are roughly the same. There were three things we have to do to listen to an event. Can you remember them? If not, we encourage you to look at the slides for the lecture on listening to GUIs, and read in the text, to become familiar with them.

One of the things to be done is to register SOMETHING to listen to mouse movement. How do you do that? What method should be called? This is something that you should be able to find out. It may be an inherited method, so check the acm-package specifications for the superclass of Breakout.

3. Problem: I finally figured out how to make the paddle listen to the mouse, but now the paddle sticks to the mouse! Whenever I move the mouse, there is the paddle, even if I move the mouse above the bricks. Why does it do this?

Aha! So you saw that Breakout extends a class, looked at that class'es methods, found one that looked suitable, and put a call on it somewhere in method run or a method called by run. Please go back to the API specs for the superclass of Breakout and read carefully the complete specification of the method --we hope the one without parameters. It talks about adding the program as both a MouseListener and MouseMotonListener to the CANVAS. Now, did you call this method that is in object Breakout? Or did you call one that is in the paddle object?

2. Question: Are we allowed to create methods of our own? Must we implement the methods as you have already written? For example, can we change one of them from a procedure into a function?

You can do anything you want, except: Add whatever methods you feel are necessary, but make sure you put precise and complete specifications for methods that you add.

1. Question: How is this assignment graded? Will we lose points for the way we write things even if it works?

This assignment is graded not only on correctness but also on your design and implementation. In this assignment, you have a lot more freedom in designing your own methods. You should follow all the principles and strategies that we have talked about over the semester. Did you write the same thing in many places instead of writing a method and calling it in several places? Are the set of methods you write a reasonable way to design this program? Do you have a method that is 100 lines long (you shouldn't)? Have you clearly specified each method you write --did you do that BEFORE you wrote the method?

We will be not be overly strict on this issue, but we reserve the right to deduct points for things that are obviously bad practice.