public class Monster {
private String hp;
private String damage;
private String speed;
public Monster(){
int x = (int)(Math.random()*100+1);
System.out.println("x"+x);
if (x ==1){
this.hp = "10000";
this.damage = "2000";
this.speed = "5";
}else if (x > 1 && x <= 11){
this.hp = "5000";
this.damage = "500";
this.speed = "2";
}else{
this.hp = "500";
this.damage = "200";
this.speed = "1";
}
}
public String getHp() {
return hp;
}
public void setHp(String hp) {
this.hp = hp;
}
public String getDamage() {
return damage;
}
public void setDamage(String damage) {
this.damage = damage;
}
public String getSpeed() {
return speed;
}
public void setSpeed(String speed) {
this.speed = speed;
}
}
public class Gun implements Weapon{
private String price;
private String damage;
private String distance;
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getDamage() {
return damage;
}
public void setDamage(String damage) {
this.damage = damage;
}
public String getDistance() {
return distance;
}
public void setDistance(String distance) {
this.distance = distance;
}
@Override
public void fire() {
// TODO Auto-generated method stub
System.out.println("枪开火");
}
@Override
public void reload() {
// TODO Auto-generated method stub
System.out.println("枪装填");
}
}
public interface Weapon {
public void fire();
public void reload();
}