forked from justinszaro/WarringNations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPeople.java
More file actions
executable file
·131 lines (116 loc) · 3.58 KB
/
People.java
File metadata and controls
executable file
·131 lines (116 loc) · 3.58 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* The People class instantiates a new person and assigns its nation, tribe, Peopletype, gets its Description from
* PeopleType.java, and assigns the persons lifepoints. The class also includes getters for the Person's PeopleType,
* Tribe, Nation, and Lifepoints. The isPersonAlive() method checks to see if the persons lifepoints > 0 and the
* modifyLifePoints() method reduces the person's Lifepoints. The toString() method outputs the current person's
* values. The encounterStrategy method currently does nothing.
*
* @author Max Schuman, Elizabeth Vicente, Tanishq Iyer, Justin Szaro
* @version 3.0
* @since 2021-04-11
*/
public abstract class People
{
private final String myNation;
private final String myTribe;
private final String myName;
private final PeopleType me;
protected String myDescription;
private int myLifePoints;
private boolean dead;
/**
* Instantiates a new person.
* The constructor makes a new person and assigns their nation, tribe, PeopleType, and amount of lifepoints.
* @param nation name of the nation
* @param tribe name of the tribe
* @param person type of created person
* @param lifePoints total lifepoints of person
*/
public People(String nation, String tribe, PeopleType person, int lifePoints, String myName)
{
myNation = nation;
myTribe = tribe;
this.myName = myName;
me = person;
myDescription = me.getDescription();
myLifePoints = lifePoints;
dead = false;
}
public String getMyDescription() {
return myDescription;
}
public String getName() {
return myName;
}
public void setDead()
{
dead = true;
}
public boolean getDead()
{
return dead;
}
/**
* Returns a persons PeopleType
* @return me Returns PeopleType of person
*/
public PeopleType getType()
{
return me;
}
/**
* Returns a person's Tribe
* @return myTribe Returns the Person's Tribe
*/
public String getTribe()
{
return myTribe;
}
/**
* Returns a persons Nation
* @return myNation Returns Person's nation
*/
public String getNation()
{
return myNation;
}
/**
* Determines whether or not a person is alive
* @return bool Returns true if lifepoints are greater than 0, if =< 0, returns false
*/
public Boolean isPersonAlive()
{
return (myLifePoints > 0);
}
/**
* Returns the current lifepoints of the Person
* @return myLifePoints Returns lifepoints of Person.
*/
public int getLifePoints() { return myLifePoints;}
/**
* Reduces or increases the Person's Lifepoints by the parameter points. A person's lifepoints is capped at 100.
* @param points Number of points a Persons LifePoints should be reduced by.
*/
public void modifyLifePoints(int points)
{
if ((myLifePoints + points ) > 100) {
myLifePoints = 100;
}
else{
myLifePoints += points;
}
}
/**
* Abstract method to makes an encounter strategy for a particular person.
* @param otherPerson Other Person who is involved in the encounter
*/
public abstract int encounterStrategy(People otherPerson);
/**
* Returns the variable values for the Person.
* @return result Returns a summary of a Person's characteristics.
*/
public String toString()
{
return new String( myNation + "\t" + myTribe + "\t" + me + "\t" + myDescription + "\t" + myLifePoints);
}
}