-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.java
176 lines (141 loc) · 4.41 KB
/
Person.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package com.johar_rewards.johar_rewards;
import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
public class Person implements Serializable {
private String username, firstName, lastName, location, department, position, story, password;
private transient Bitmap image;
private int points, pointsToAward;
private boolean admin;
JSONArray rewards;
public String toString() {
return "Person{" +
"username='" + username + '\'' +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", location='" + location + '\'' +
", department='" + department + '\'' +
", position='" + position + '\'' +
", story='" + story + '\'' +
", password='" + password + '\'' +
", image='" + image + '\'' +
", points=" + points +
", pointsToAward=" + pointsToAward +
", admin=" + admin +
", rewards=" + rewards +
'}';
}
public Person(){
}
public Person(String firstName, String lastName, String username, String department, String story, String position, String password,
int pointsToAward, boolean admin, Bitmap image, String location, JSONArray rewards){
this.firstName = firstName;
this.lastName = lastName;
this.username = username;
this.department = department;
this.story = story;
this.position = position;
this.password = password;
this.pointsToAward = pointsToAward;
this.admin = admin;
this.image = image;
this.location = location;
this.rewards = rewards;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getStory() {
return story;
}
public void setStory(String story) {
this.story = story;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Bitmap getImage() {
return image;
}
public void setImage(Bitmap image) {
this.image = image;
}
public int getPoints() {
return points;
}
public void setPoints(int points) {
this.points = points;
}
public int getPointsToAward() {
return pointsToAward;
}
public void setPointsToAward(int pointsToAward) {
this.pointsToAward = pointsToAward;
}
public boolean isAdmin() {
return admin;
}
public void setAdmin(boolean admin) {
this.admin = admin;
}
public JSONArray getRewards() {
return rewards;
}
public void setRewards(JSONArray rewards) {
this.rewards = rewards;
}
public static int calcPoints(JSONArray rewards) {
rewards = rewards;
int points = 0;
for (int i = 0; i < rewards.length(); i++){
try {
JSONObject obj = rewards.getJSONObject(i);
int currPoint = obj.getInt("value");
points = points + currPoint;
} catch (JSONException e) {
e.printStackTrace();
}
}
return points;
}
}