Created
April 14, 2014 19:33
-
-
Save tadams/10676669 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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