After you have filled your array of Circles you can loop through that array and use your getColour() method to get the colour of each Circle. Test if that is red, and increment a counter if it is.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
basically, the same way you always compare Strings, by the equals method.
have you tried to do what JamesCherrill suggested?
if you have any trouble implementing it, show us what you tried.
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
test[i].getCouleur() returns the String you have to compare with equals
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
On line 19 you have the colour for each circle. Now see if that is "red". You already have some hints on how to compare Strings.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
yes
but only if you enter red as parameter also in lower cases, and:
test[i].getColour(); // you don't use this line, so it can be left out.
if (test[i].getColour().equals("red"))
{
}
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
That's great. Well done.
Just one small suggestion: if you use the very useful method equalsIgnoreCase rather than just equals, then it won't matter whether you have red Red or RED.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073