-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountry.java
106 lines (81 loc) · 2.92 KB
/
Country.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import java.util.ArrayList;
public class Country{
protected String name;
protected String adjective; //Used primarily for the naming of wars
protected double land;
protected int troopMax;
protected int troopCount;
protected int opinionFrance;
protected int prestige;
protected int aggressiveness;
protected int conflicts;
public Country(String newName,String newAdj, double newLand, int newAt, int newDf, int prest, int op, int agg,int nconflicts){
name = newName;
adjective = newAdj;
land = newLand;
troopMax = newAt;
troopCount = newDf;
prestige = prest;
opinionFrance = op;
aggressiveness = agg;
conflicts = nconflicts;
}
/////////////
//ACCESSORS//
/////////////
public String getName(){return name;}
public String getAdj(){return adjective;}
public double getLand(){return land;}
public int getTroopMax(){return troopMax;}
public int getTroopCount(){return troopCount;}
public int getPrestige(){return prestige;}
public int getOpinion(){return opinionFrance;}
public int getAggresive(){return aggressiveness;}
public int getConflict(){return conflicts;};
//////////////
///MUTATORS///
/////////////
public double addLand(double newLand){land+=newLand; return land-newLand;}
public double subLand(double lostLand){land-=lostLand; return land + lostLand; }
public double setLand(double newLand){double old = land; land=newLand; return old;}
public int setTroopMax(int newVal){int old = troopMax; troopMax=newVal; return old;}
//Mutators with caps
public int changeTroopCount(int newVal){int old = troopCount; troopCount=newVal;
if (troopCount > troopMax){
troopCount = troopMax;}
else if (troopCount < 0){
troopCount = 0;}
return old;}
public void setName(String newVal){
name = newVal;}
public int setPrestige(int newVal){int old = prestige; prestige= newVal;
if (prestige > 100){
prestige = 100;}
else if( prestige < 0){prestige = 0;}
return old;}
public int setOpinion(int newVal){int old = opinionFrance; opinionFrance= newVal;
if (opinionFrance > 100){
opinionFrance = 100;}
else if(opinionFrance < -50){opinionFrance = -50;}
return old;}
public int changeAggressive(int add){int old = aggressiveness; aggressiveness += add;
if (aggressiveness > 100){
aggressiveness = 100;}
if (aggressiveness < 0){
aggressiveness = 0;}
return old;}
//Used in the naming of wars
public void conflictIncrement(){conflicts+=1;}
//Default Country toString()
public String toString(){
String retStr=("\nName: "+getName()+
"\n\tLand: "+getLand()+
"\n\tTroop Count: "+getTroopCount()+
"\n\tPrestige: "+getPrestige()+
"\n\tOpinion of France: "+ getOpinion()+
"\n\tAgressiveness: "+getAggresive()
//"\n\tConflict Count:"+getConflict()
);
return retStr;
}
}