I have been asked to write a public method called Caught() which takes a single argument of type LittleAlien and returns no result, for the AlienGame class. The method should check whether the argument occupies a stone corresponding to the stone occupied by the BigAlien. If so, the health of the argument should be updated accordingly.

default setting for BigAlien is 7
default setting for LittleAlien is 3

Would I need to use public void updateHealth() method in the AlienGame class? The reason I say this is iIn earlier question I was asked to write a public method called updateHealth for class LittleAlien.

public class LittleAlien extends BigAlien
{
   public void updateHealth()
   {
     if (this.getColour() == OUColour.GREEN)
        {
          this.setColour(OUColour.RED);  
        }

    else if (this.getColour() == OUColour.RED)
        {
          this.setColour(OUColour.BLACK);  
        } 

   }
}

public class AlienGame 
{
  public void Caught(LittleAlien aLalien)
  {

  }

}

I don't think anyone understand my question. Does first paragraph makes sense?

The updateHealth method is of the LittleAlien class, so in the method Caught, you can do this:

public void Caught(LittleAlien aLalien)
{
   aLalien.updateHealth();
}

Also more code would be required. And I don't think that LittleAlien should extend BigAlien, but I could be wrong. Post your requirements as well.

commented: 1 +1

Thats all I wanted to know thaks javaAddict

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.