This shows you the differences between the selected revision and the current version of the page.
| courses:cs102-200903:labs:lab6 2009/10/29 15:40 | courses:cs102-200903:labs:lab6 2009/10/29 15:42 current | ||
|---|---|---|---|
| Line 71: | Line 71: | ||
| | public void draw() | | | public void draw() | | ||
| +-------------------------------------+ | +-------------------------------------+ | ||
| + | |||
| Line 92: | Line 93: | ||
| - Make ''TrafficLight'' extend ''World'' using the keyword ''extends''. \\ \\ | - Make ''TrafficLight'' extend ''World'' using the keyword ''extends''. \\ \\ | ||
| - Create the six fields shown in the class diagram above in ''TrafficLight'' and write a three-parameter constructor to set the ''on'', ''next'', and ''third'' fields. \\ \\ | - Create the six fields shown in the class diagram above in ''TrafficLight'' and write a three-parameter constructor to set the ''on'', ''next'', and ''third'' fields. \\ \\ | ||
| - | - Write the ''onTick'' method in ''TrafficLight''. The effect of this method will be to rotate the Bulbs such that ''on'' is assigned the object ''next'', ''next'' is assigned the object ''third'', and ''third'' is assigned the object ''on''. Remember the example you were shown in class when writing this method and //beware the destructive nature of assignment// (also, you can consult page 406 of our text to see how this method should be written). \\ \\ | + | - Write the void ''onTick'' method in ''TrafficLight''. The effect of this method will be to rotate the Bulbs such that ''on'' is assigned the object ''next'', ''next'' is assigned the object ''third'', and ''third'' is assigned the object ''on''. Remember the example you were shown in class when writing this method and //beware the destructive nature of assignment// (also, you can consult page 406 of our text to see how this method should be written). \\ \\ |
| - | - Write the ''onKeyEvent'' method in ''TrafficLight'' such that it does nothing and returns nothing for this part of the assignment. \\ \\ | + | - Write the void ''onKeyEvent'' method in ''TrafficLight'' such that it does nothing and returns nothing for this part of the assignment. \\ \\ |
| - | - Write the ''draw'' method in ''TrafficLight'' to first draw a black rectangle of size WIDTH and HEIGHT on ''theCanvas'', then call the correct methods in ''Bulb'' to draw the bulb that is currently ''on'', and to draw the other two bulbs as ''off''. Remember, you should use the ''Canvas'' object called ''theCanvas'' that is inherited from the ''World'' class when drawing each of these parts. \\ \\ | + | - Write the void ''draw'' method in ''TrafficLight'' to first draw a black rectangle of size WIDTH and HEIGHT on ''theCanvas'', then call the correct methods in ''Bulb'' to draw the bulb that is currently ''on'', and to draw the other two bulbs as ''off''. Remember, you should use the ''Canvas'' object called ''theCanvas'' that is inherited from the ''World'' class when drawing each of these parts. \\ \\ |
| When you have completed the steps above and have removed all errors from your code, go on to Part III. You have to add a class with a main method in order to make the animation run and that is the subject of Part III. | When you have completed the steps above and have removed all errors from your code, go on to Part III. You have to add a class with a main method in order to make the animation run and that is the subject of Part III. | ||