Ryerson University
School of Computer Science
CPS209 Term Test #1A : Winter 2006
Worth = 15%; Time limit = 50 minutes; No aids

Name:____________________________________ Student #: ______________________

Section #: ______________________
A. (1 point each)
  1. polymorphism.
  2. interface.
  3. interface.
  4. inner class: Give two reasons why one might write a class as an inner class rather than a top-level class?
  5. drawing: Write a panel's paintComponent which draws a rectangle with an X in it (i.e., the two diagonal lines are in it).<
              public void paintComponent(Graphics g)
                  Graphics2D g2 = (Graphics) g ;

B. (10 points) Fill in the following two classes Egg and EggPanel EggPanel. Egg is basically an ellipse with a few extra methods, and EggPanel is a panel that draws a dozen eggs lined up. There is a timer which causes sorting of the eggs, so that every couple of seconds the order switches from shortest-to-tallest to tallest-to-shortest. Solutions: Egg.java and EggPanel.java ( and to try it out: EggPanelDriver.java)