So I have two classes that each should use the "same" method from their superclass, however there is one variable that should changed depending on the class calling it.
The variable that should change depending on the class calling the method is "VARIABLE ". If it is the enemyShip calling this method and it is indeed touching the PlayerBullet.class it should change the "VARIABLE" to "enemyHP". If it is the bossShip calling this method and is touching the bullet it should change the variable to "bossHP".
I'm not sure if this is possible, but I would appreciate it if someone gave it a go. As you can see, I only need to change one variable in the method for it to be useful for two classes, so I really don't want to copy and paste the code into each of the classes, or make two very similar methods.
public void checkForBullet()
{
if (getOneIntersectingObject(PlayerBullet.class) != null)
{
if(VARIABLE > 0)
{
getWorld().removeObject(getOneIntersectingObject(PlayerBullet.class));
VARIABLE --;
}
else
{
getWorld().removeObject(getOneIntersectingObject(PlayerBullet.class));
GameWorld gameworld = (GameWorld)getWorld();
Counter counter = gameworld.getCounter();
counter.addScore();
gameworld.killCount();
getWorld().removeObject(this);
}
}
}
