forked from mastifikator/FantasyJavaPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmy.java
More file actions
48 lines (36 loc) · 824 Bytes
/
Copy pathArmy.java
File metadata and controls
48 lines (36 loc) · 824 Bytes
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
package Composite;
import java.util.ArrayList;
public class Army implements IMilitary{
private int strength = 0;
private String name ="";
ArrayList<Squad> squads = new ArrayList<>();
public Army(String name) {
this.name = name;
}
public Army() {
}
public void setName(String name) {
this.name = name;
}
public ArrayList<Squad> getSquads() {
return squads;
}
public boolean addSquad(Squad squad){
return squads.add(squad);
}
@Override
public String getName() {
return name;
}
@Override
public String getType() {
return "Армия";
}
@Override
public int getPower() {
for(Squad s : squads){
strength += s.getPower();
}
return strength;
}
}