This repository was archived by the owner on Feb 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeamManager.java
More file actions
53 lines (45 loc) · 1.51 KB
/
Copy pathTeamManager.java
File metadata and controls
53 lines (45 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package AdventureRPG;
import java.util.Scanner;
import java.util.ArrayList;
public class TeamManager extends Main {
Scanner inputUser = new Scanner(System.in);
ArrayList<Karakter> teemate = new ArrayList<>();
// add karakter
public void addTeam() {
boolean running = true;
while (running == true) {
System.out.print("add name : ");
String name = inputUser.nextLine();
String type = inputUser.nextLine();
try {
if (type.equalsIgnoreCase("mage")) {
teemate.add(new Mage(name));
} else if (type.equalsIgnoreCase("healer")) {
teemate.add(new Healer(name));
} else if (type.equalsIgnoreCase(type)) {
teemate.add(new Fighter(name));
} else {
throw new NoName("Notfound");
}
} catch (NoName e) {
System.out.println("error : " + e.getMessage());
}
System.out.print("Add again (y/n) : ");
String cn = inputUser.nextLine();
if (cn.equalsIgnoreCase("y")) {
running = true;
} else {
running = false;
}
}
}
public void show() {
for (Karakter karakter : teemate) {
karakter.role();
karakter.action();
if (karakter instanceof CanAttack) {
((CanAttack) karakter).attack();
}
}
}
}