forked from mastifikator/FantasyJavaPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit.java
More file actions
43 lines (35 loc) · 1007 Bytes
/
Unit.java
File metadata and controls
43 lines (35 loc) · 1007 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
package Singletone;
public class Unit {
private String race;
private String proffesion;
private String name;
private static Unit instance;
public void setRace(String race) {
this.race = race;
}
public void setProffesion(String proffesion) {
this.proffesion = proffesion;
}
public void setName(String name) {
this.name = name;
}
private Unit(String race, String proffesion, String name) {
this.race = race;
this.proffesion = proffesion;
this.name = name;
}
public static Unit getInstance(String race, String proffesion, String name){
if(instance == null){
instance = new Unit(race, proffesion, name);
}
return instance;
}
@Override
public String toString() {
return "Unit{" +
"race='" + race + '\'' +
", proffesion='" + proffesion + '\'' +
", name='" + name + '\'' +
'}';
}
}