Midterm #2 -- The Dashboard Midterm

1) (Yes/No) Should one put a class inside another class.  In other words, is this OK?
public class Stickshift
{
     class Knob
     {
      ....
     }
     ....
}

2) Suppose that your program has three classes, all of which have a paint method.  Which paint does the system call when it wants the screen redrawn?



3) When should you have a program with more than one class, each class having it's own mousePressed() method?



4) Write me a program.  This program should have three buttons labeled 'Seat Belt', 'Antilock Brakes', and 'Engine'.  When you click on the button it should disappear.  When you click where the button was, it should reappear.  You get one point for every task below.


5) Write me a program.  This program should have two buttons and a slider bar.  The buttons should be labeled "Full" and "Less".  The slider bar should have a 'F' to the left and a 'E" to the right.  When the 'Full' button is pressed, the slider bar should be fully left.  If the 'Less' button is pressed, the slider bar should move right.  It should be impossible to go below empty.  You get one point for every task below.