In Java, a String is an object...
You ask the block to give it's color so you can determine if it is food or enemy. You are not sure what type to return from the method. You need to think about what...
Type: Posts; User: jps
In Java, a String is an object...
You ask the block to give it's color so you can determine if it is food or enemy. You are not sure what type to return from the method. You need to think about what...
What type do you need to be able to compare to a color?
Is the color stored in a variable in your block object? Write a method that returns that value. You can search for samples with keywords...
We can move threads if they need moved. I merged your threads for the same question.
This seems like a normal way to interact with an object.
I don't think the getColor method of java.awt.Color will return the color of your block. Suggested reading.
What happened when you...
How about:
Seems (with the limited code provided.....) there should be a getColor and setColor method in your block class.
Then in your (posted) for loop something like:
for.........
if...