The most proper to do this is to have an object representing the combination of values you have;
public class Enemy {
private String name;
private Integer healthPoint;
private Integer manaPoint;
private Integer attackPower;
// getter, setter, constructors
// example constructor
public Enemy(String name, Integer hp, Integer mp, Integer ap) {
this.name = name;
this.healthPoint = hp;
this.manaPoint = mp;
this.attackPower = ap;
}
}
Then represent this with a map if you'd like, by doing;
List<Enemy> enemies = new ArrayList<>();
enemies.add(new Enemy("Weak Skeleton", 100, 0, 100));
enemies.add(new Enemy("Blue Slime", 50, 0, 25));
enemies.add(new Enemy("Novice Rogue Mage", 25, 100, 0));
Map<String, Enemy> enemyMap = enemies.stream().collect(Collectors.groupingBy(Enemy::getName));
So if you'd need to access and edit any value, it is easy via;
enemyMap.get("Weak Skeleton").setAttackPower(75);
or to add a new enemy;
Enemy dragonBoss = new Enemy("Dragon Boss", 1000, 500, 250);
enemyMap.put(dragonBoss.getName(), dragonBoss);
Though, I'd suggest using some enumeration to identify each enemy, trying to access with name String is not the best practice.
public enum EnemyType {
WEAK_SKELETON("Weak Skeleton"), BLUE_SLIME("Blue Slime"), NVC_ROGUE_MAGE("Novice Rogue Mage");
private String name;
public String getName() {
return this.name;
}
private EnemyType (String name) {
this.name = name;
}
}
And using it as name/key in map.
You'd be better off with Lombok, to chain setters if you'd want, plus it reduces a lot of boilerplate code (getters, setters, constructors). Check @Data with @Accessors(chain = true)
Map<String, String[]>orMap<String, List<String>>to store that.Enemyclass withhp,mpandatkfields. Then create a collection ofEnemyobjects. No point in doing OO if you're not gonna use objects.Object[]but you get no type safety that way."easy"!="nice"