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)
  {

  }

}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

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.

Comments
1
This question has already been answered. Start a new discussion instead.