how do i check the object status with another object
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)
{
}
}
ttboy04
Junior Poster in Training
53 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
I don't think anyone understand my question. Does first paragraph makes sense?
ttboy04
Junior Poster in Training
53 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
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.
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
Thats all I wanted to know thaks javaAddict
ttboy04
Junior Poster in Training
53 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0