-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonsterParser.java
More file actions
23 lines (22 loc) · 929 Bytes
/
MonsterParser.java
File metadata and controls
23 lines (22 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class MonsterParser {
public static Team Parse(String data){
MonsterTeam result = new MonsterTeam("");
String[] monstersData = data.split(";");
for (String monsterInfo : monstersData) {
String[] monsterDetails = monsterInfo.split(",|\\(|\\)");
String monsterName = monsterDetails[0];
String monsterType = monsterDetails[1];
String monsterLevel = monsterDetails[2];
if(monsterType=="Minion") {
Minion minion = new Minion(monsterName);
minion.setLevel(Integer.parseInt(monsterLevel));
result.addMember(minion);
} else if(monsterType=="Boss") {
Boss boss = new Boss(monsterName);
boss.setLevel(Integer.parseInt(monsterLevel));
result.addMember(boss);
}
}
return result;
}
}