Skip to content

Instantly share code, notes, and snippets.

@tadams
Created April 14, 2014 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadams/10676669 to your computer and use it in GitHub Desktop.
Save tadams/10676669 to your computer and use it in GitHub Desktop.
package com.tom.zombie;
public class Zombie {
public enum Type {
WALKER(1),
RUNNER(1),
FATTY(2),
ABOMINATION(3);
int maxDamagePoints;
private Type(int maxDamagePoints) {
this.maxDamagePoints = maxDamagePoints;
}
public boolean isKillAttack(int damagePoints) {
return damagePoints >= maxDamagePoints;
}
public int getMaxDamagePoints() {
return maxDamagePoints;
}
}
Type type;
boolean isAlive = true;
public Zombie(Type type) {
this.type = type;
}
public void attack(int damagePoints) {
if (type.isKillAttack(damagePoints)) {
isAlive = false;
}
}
public boolean isAlive() {
return isAlive;
}
public Type getType() {
return type;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment