Re: Help with resetting a class. *Beginner
s9_at_r\)\(
Date: 03/10/04
- Next message: s1h1: "Re: Help with resetting a class. *Beginner"
- Previous message: Phil Powell: "Re: JAR/JSP help"
- In reply to: Christophe Vanfleteren: "Re: Help with resetting a class. *Beginner"
- Next in thread: s1h1: "Re: Help with resetting a class. *Beginner"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 10 Mar 2004 15:09:52 -0000
"Christophe Vanfleteren" <c.v4nfl3t3r3n@pandora.be> wrote in message
news:RAF3c.29753$_S6.2024509@phobos.telenet-ops.be...
> s9@r)( wrote:
>
> > Hi,
> >
> > The following 3 private methods are used to set the color, radius, and
> > location of an object - straightforward enough! How can I use a 4th
method
> > to reset the first three after an initial instance has been created?
> >
> > private void setColor();
> > private void setRadius();
> > private void setLoc();
> >
> > public void resetDidge();
> >
> > TIA
> >
> > SparX
>
> Keep the old values of those properties around:
>
>
> public class XXX {
> private Color oldColor;
> private Color currentColor;
>
>
> public void setColor(Color c) {
> if(c == currentColor) {
> return;//nothing changed
> }
> oldColor = currentColor;
> currentColor = c;
> }
>
> public void reset() {
> setColor(oldColor);
> ...
> }
> }
>
>
> --
> Kind regards,
> Christophe Vanfleteren
Thanks for that, but I'm still a little stuck:
The setColor method sets the Didge color to a color in the array:
private final Color[] colors =
{Color.blue, Color.black, Color.cyan, Color.green,
Color.gray, Color.magenta, Color.orange, Color.pink,
Color.red, Color.white, Color.yellow};
Taking that into account how can I make the public method invoke the other
three to reset the location, radius and color methods.
Sorry if this sounds dumb - I am somewhat!
TIA
- Next message: s1h1: "Re: Help with resetting a class. *Beginner"
- Previous message: Phil Powell: "Re: JAR/JSP help"
- In reply to: Christophe Vanfleteren: "Re: Help with resetting a class. *Beginner"
- Next in thread: s1h1: "Re: Help with resetting a class. *Beginner"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|