0

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 by mike_2000_17: Fixed formatting

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by ttboy04
Featured Replies
  • The updateHealth method is of the LittleAlien class, so in the method Caught, you can do this: [CODE] public void Caught(LittleAlien aLalien) { aLalien.updateHealth(); } [/CODE] 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 … Read More

0

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

1

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.