Trying to change the color of an object depending on if/else statement

Hi, all-

I'm trying to use an if/else statement to determine the color of an object. Here's what the outside method that draws the color looks like, as well as the if/else statement that needs to be able to change the color of the object. The problem is that I need this logic to operate in the opposite direction. I need the SimGraphics method to be called directly in the if/else statement, so that the drawFastRoundRect( Color.whatever ) command works INSIDE that if/else statement. Can I do that? If so, how?

publicvoid draw( SimGraphics g ){

g.drawFastRoundRect( Color.blue );

if (colorMeSurprised ==1){

g.drawFastRoundRect( Color.magenta );

}

elseif (colorMeSurprised == 2){

g.drawFastRoundRect( Color.pink);

}...

for (int i = 0; i < threeNeighborVectors.size(); i++ );

if (surferNeighbors.size() > swimmerNeighbors.size()){

iHaveMoreSurferNeighbors.add(aOcean);

colorMeSurprised = 1;

}

elseif (swimmerNeighbors.size() > surferNeighbors.size()){

iHaveMoreSwimmerNeighbors.add(aOcean);

colorMeSurprised = 2;

}

[1711 byte] By [tarahmariea] at [2007-10-3 3:30:40]
# 1
so, what exactly is your problem?
Redxxiva at 2007-7-14 21:24:35 > top of Java-index,Java Essentials,Java Programming...
# 2

> so, what exactly is your problem?

Let me repeat it one more time; I need the color to change IN the if/else statement by calling on an outside method. I cannot pass a value from the if/else statement to an outside method; I need it to work the other way around. Please carefully read posts; I get yelled at enough for not reading carefully, so please do your part as well.

tarahmariea at 2007-7-14 21:24:35 > top of Java-index,Java Essentials,Java Programming...
# 3
hi,What is the signature of the method g.drawFastRoundRect( Color.magenta );bye for nowsat
AnanSmritia at 2007-7-14 21:24:35 > top of Java-index,Java Essentials,Java Programming...
# 4

> Please carefully read posts; I get yelled at enough for not reading carefully, so please do your part as well.

I've read you question 5 times and still have no idea what you are asking.

> I need the SimGraphics method to be called directly in the if/else statement

SimGraphics isn't a method its a class, so I still don't know what you mean.

Instead of yelling at people trying to help, you should spend more time making understandable questions.

Posting a few lines of random code doesn't give us much information to work with either.

camickra at 2007-7-14 21:24:35 > top of Java-index,Java Essentials,Java Programming...
# 5
> I need the color to change IN the if/else statement This doesn't make much sense. What "color" is this you need to change? Perhaps you mean you want the code in the if/else statement to make some colour change?
DrClapa at 2007-7-14 21:24:35 > top of Java-index,Java Essentials,Java Programming...
# 6
hiwhat i could make of query isu want draw(SimGraphics ) to be called in if -else of forif that's the case i will help u
vipuluckya at 2007-7-14 21:24:35 > top of Java-index,Java Essentials,Java Programming...
# 7

> hi

> what i could make of query is

> u want draw(SimGraphics ) to be called in if -else

> of for

> if that's the case i will help u

Thank God! Do you know how to do that? I've been so frustrated because though I need to call draw(SimGraphics) inside that if/else statement in another method, it's not good code, nor have I been able to take the advice of so many people on this site who have given me good code tips. Since I HAVE to do it this way (it's a class assignment, and hence not something I can work around), I would certainly appreciate any help you can give me.

tarahmariea at 2007-7-14 21:24:35 > top of Java-index,Java Essentials,Java Programming...
# 8
u made a silly mistakefor ( int i = 0; i < threeNeighborVectors.size(); i++ );their is semicolon after for loop which will make it terminate at the very first stepget it off and keep on goingRegardsVipul
vipuluckya at 2007-7-14 21:24:35 > top of Java-index,Java Essentials,Java Programming...