LCCC Course CIS 210 - Java Programming |
|
Java Programming Assignment 3Modify the PetRockApplet program to: * Make your pet a circle or oval rather than a rectangle See your instructor
or textbook for drawing methods To modify your PetRock to change colors : 1. You will need to declare two instance variables for the colors (you'll have to decide where in the class to put these two lines): private Color color1;
color1 = Color.red; 3. How should you write another method like the flip() method that
will swap the colors? 4. How should you modify the paint() method to use color1? Bonus Assignment:* Use an oval and have 2 buttons (one to flip and one to change color) public void actionPerformed(ActionEvent e) { if (e.getSource() == flipButton) // check if flipButton was clicked { flip(); } if (e.getSource() == colorButton) // check if colorButton clicked { changeColor(); } repaint(); // redraw the picture } // this ends the actionPerformed method |
|
Last Updated: January, 2011 |