Im trying to create a class that has a base object. The base object will be used to create a few objects and be made to 'fight' in another class based on strength and powerups.
I have got this error when compiling 'Error, unreachable statement' and it points to line 27 pointing to the return, can someone help me out please?
public class Superhero {
private String superheroName;
private int superheroStrength;
public int powerUp;
public Superhero (String superheroName, int superheroStrength, int powerUp){
this.superheroName = superheroName;
this.superheroStrength = superheroStrength;
System.out.println("Superhero: " + superheroName);
System.out.println("Strength: " + ( superheroStrength + powerUp));
}
public Superhero (String superheroName, int powerUp){
this.superheroName = superheroName;
superheroStrength = 10;
System.out.println("Strength: " + ( superheroStrength+powerUp));
}
public int getStrength(){
return superheroStrength += powerUp;
}
public void powerUp (int powerUp){
this.powerUp += powerUp;
}
public Superhero battle(Superhero1 opponent){
if (this.getStrength()>opponent.getStrength());
return this;
return opponent;
}
public String toString(){
return this.superheroName;
}
}