package polymorphism;
public class Hero {
int moveSpeed; //移动速度
public boolean equals(Object o){
if(o instanceof Hero){
Hero h = (Hero) o;
return this.hp == h.hp;
}
return false;
}
public int getMoveSpeed(){
return this.moveSpeed;
}
public int getMoveSpeed2(){
return 199;
}
}
package polymorphism;
public class ADHero extends Hero {
int moveSpeed=3; //移动速度
public int getMoveSpeed(){
return this.moveSpeed;
}
public int getMoveSpeed2(){
return super.moveSpeed;
}
public static void main(String[] args) {
Hero h1=new Hero();
h1.moveSpeed = 300;
Hero h2=new ADHero();
h2.moveSpeed = 300;
System.out.println(h2.getMove