How can I use an abstract method with Overriding on two classes.? But these two classes have the same method but different parameters. Is there any solution or should I make the method not abstract and type for each class differently?
public abstract int attack(Object object); // here is my abstract method from Character class
public int attack(Hero hero){ // this method from monster class
int currentHeroHealth;
int reducedDamage;
System.out.println("You have been attacked by monster!");
int attackDamage = getAttackDamage();
int attackSpeed = getAttackSpeed();
int attack = attackDamage * attackSpeed;
if(attack<hero.getArmor()){
reducedDamage=hero.getArmor()-attack;
}
else{
reducedDamage=attack-hero.getArmor();
}
currentHeroHealth=hero.getHealthPoints()-reducedDamage;
hero.setHealthPoints(currentHeroHealth);
return currentHeroHealth;
}
public int attack(Monster monster) { // this method from hero class
System.out.println("You attacked to monster!");
int currentMonsterHealth=monster.getHealthPoints()-HitPoints;
if(currentMonsterHealth==0){
System.out.println("You defeated the monster"+monster.getName());
monster.setHealthPoints(0);
}
else {
monster.setHealthPoints(currentMonsterHealth);
}
return currentMonsterHealth;
}