Skip to content

Instantly share code, notes, and snippets.

@adilkurniaramdan
Created April 30, 2013 12:15
Show Gist options
  • Save adilkurniaramdan/5488346 to your computer and use it in GitHub Desktop.
Save adilkurniaramdan/5488346 to your computer and use it in GitHub Desktop.
//MainDota.java
public class MainDota {
public static void main(String[] args) {
Hero hero1 = new Hero();
hero1.setId(1);
hero1.setName("Huskar");
hero1.setAbility(EnumAbility.STRENGTH.getAbility());
Hero hero2 = new Hero();
hero2.setId(2);
hero2.setName("Nortom");
hero2.setAbility(EnumAbility.INTELEGENCE.getAbility());
Hero hero3 = new Hero();
hero3.setId(3);
hero3.setName("Kardel");
hero3.setAbility(EnumAbility.AGILITY.getAbility());
}
}
//Hero.java
public class Hero {
private int id;
private String name;
private int ability;
//setter getter are hidden
}
//EnumAbility.java
public enum EnumAbility {
AGILITY(1),STRENGTH(2),INTELEGENCE(3);
private int ability;
EnumAbility(int ability){
this.ability=ability;
}
public int getAbility() {
return ability;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment