Wednesday, January 24, 2007

Lab 2 clarification

Refered to: http://www.whizbangscholar.com/EB/010%20Lab%202%20W07%20B.pdf

There is a slight typo in the original lab write-up. On the line that says
public class
Alien extends wheels.users.Frame { ... }
It should have been
public class AlienApp extends wheels.users.Frame { ... }

In other words, the Alien class should NOT extend wheels.users.Frame. It does NOT need to extend anything. In fact, when write the Alien class, the header should be simply:
public class Alien { ... }

The AlienApp class, however, needs to "extends wheels.users.Ellipse".

You do not need to know what "extends" mean at this point. It has not been covered yet (but will be soon). If you are curious, read Chapter 3 on Inheritance.

QUESTION: Where should I put my main method?
Answer: The AlienApp class MUST have a main method. The Alien class does not need a main method.

QUESTION: How will my program be graded?
Answer:
We will do the following...
  • First, we will compile your program by...
    javac *.java
    If this creates an error, lots of points will be deducted. So, you must check to make sure there is no error at this point. If there is a "warning", minor points may be deducted.

  • Next, we will run AlienApp by
    java AlienApp
    If it doesn't run, or if it says the class is missing, or the main method is missing, your functionality points will be greatly affected (possibly zero!). So, make sure that AlienApp has a main method.

  • We will look at the result, we must see something like the following:

    That is, it must have 5 aliens on the same window. Note that alien #5 looks like alien #3 because he just winked and unwinked so rapidly our eye could not see.

    Your aliens don't have to look exactly like these. You may arrange them in a different ways -- just make sure we can see them all. Also, you can include your creativity by including a nose, a hat, ears, eyeglasses, body, ... whatever. Try to practice with different ways to draw things in wheels.

    If your program runs fine in this step, you will get a very good score.

  • We will try clicking on the alien face to see if you have implemented the extra credit.

  • Next, we will look at your code. You should submit only 2 classes:
    Alien.java and AlienApp.java
    If you have more files and they create errors, this may affect your score.

    We will look for the 4 methods specified in the lab write-up: moveTo, turnGreen, wink, and unwink.

    We will also look to see if you really made alien #5 wink and then unwink.

    Be sure to organize your code nicely. At least, you must indent your code, write your name and date at the top, include a short description of the program. Provide some comments.
QUESTION: I attempted the extra credit, but couldn't get mousePressed to work. Why?

You should put mousePressed method in Alien class. Also, modify the header of your Alien class to the following:

public class Alien extends wheels.users.Ellipse { ... }

This will make the Alien itself an ellipse which can be clicked by the user. However, it will create an extra red dot at the center of the screen. This is fine. When we click at the red dot, it will turn the alien to green & winked state.

Can you get rid of the red dot? (For the answer, visit my office hours -- Thurs 12-3pm @ Phelp 1413)

Even more fun: try to implement
public void mouseReleased(java.awt.event.MouseEvent e) { ... }

so that the alien only turn green and wink when the user holds down the mouse button. When the mouse button is released, the alien should turn white and unwinked again.

No comments:

Contributors