Search:

Type: Posts; User: jps

Search: Search took 0.21 seconds.

  1. Replies
    14
    Views
    3,664

    Re: Writing a getColor() method

    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...
  2. Replies
    14
    Views
    3,664

    re: Writing a getColor() method

    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...
  3. Replies
    14
    Views
    3,664

    Re: Writing a getColor() method

    We can move threads if they need moved. I merged your threads for the same question.
  4. Replies
    14
    Views
    3,664

    re: Writing a getColor() method

    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...
  5. Replies
    14
    Views
    3,664

    re: Writing a getColor() method

    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...
Results 1 to 5 of 5