forked from DSGGGEZ/OOAD-Project-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMember.java
More file actions
156 lines (137 loc) · 4.8 KB
/
Copy pathMember.java
File metadata and controls
156 lines (137 loc) · 4.8 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
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
public class Member extends Person {
static String[] citizen_id = new String[100];
static String[] member_name = new String[100];
static String[] address = new String[100];
static String[] email = new String[100];
static String[] telephone = new String[100];
static int[] balance = new int[100];
static int limit = 1;
Member(int member_id, String member_password, String citizen_id, String member_name, String address, String email,
String telephone, int balance) {
super.personId[limit] = member_id;
super.password[limit] = member_password;
Member.citizen_id[limit] = citizen_id;
Member.member_name[limit] = member_name;
Member.address[limit] = address;
Member.email[limit] = email;
Member.telephone[limit] = telephone;
Member.balance[limit] = balance;
}
// -----------------------------------------getMethod-----------------------------------------------
public int getMemberId(int id) {
int idMember = 0;
for (int i = 0; i <= limit; i++) {
if (personId[i] == id) {
idMember = personId[i];
}
}
return idMember;
}
public String getMemberPassword(int id) {
String passwordMember = "";
for (int i = 0; i <= limit; i++) {
if (id == personId[i]) {
passwordMember = password[i];
}
}
return passwordMember;
}
public String getMemberCitizenId(int id) {
String idCitizen = "";
for (int i = 0; i <= limit; i++) {
if (id == personId[i]) {
idCitizen = citizen_id[i];
}
}
return idCitizen;
}
public static String getMemberName(int id) {
String nameMember = "";
for (int i = 0; i <= limit; i++) {
if (id == personId[i]) {
nameMember = member_name[i];
}
}
return nameMember;
}
public String getAdress(int id) {
// String addressM = "";
// for (int i = 0; i <= limit; i++) {
// if (id == member_id[i]) {
// addressM = address[i];
// }
// }
return address[id];
}
public String getEmail(int id) {
String emailM = "";
for (int i = 0; i <= limit; i++) {
if (id == personId[i]) {
emailM = email[i];
}
}
return emailM;
}
public String getTelephone(int id) {
String telephoneM = "";
for (int i = 0; i <= limit; i++) {
if (id == personId[i]) {
telephoneM = telephone[i];
}
}
return telephoneM;
}
public int getBalance(int id) {
int balanceM = 0;
for (int i = 0; i <= limit; i++) {
if (id == personId[i]) {
balanceM = balance[i];
}
}
return balanceM;
}
// -----------------------------------------SetMethod-----------------------------------------------
public static void setMemberData(int limP, int id, String name_member, String password_member, String idCitizen,
String addressM, String emailM, String telephoneM, int balanceM) {
limit += limP;
personId[limit] = limit;
member_name[limit] = name_member;
password[limit] = password_member;
citizen_id[limit] = idCitizen;
address[limit] = addressM;
email[limit] = emailM;
telephone[limit] = telephoneM;
balance[limit] = balanceM;
}
// -----------------------------------------EditMethod-----------------------------------------------
public static void editMemberData(int selectId, String name_member, String password_member,
String idCitizen, String addressM, String emailM, String telephoneM, int balanceM) {
member_name[selectId] = name_member;
password[selectId] = password_member;
citizen_id[selectId] = idCitizen;
address[selectId] = addressM;
email[selectId] = emailM;
telephone[selectId] = telephoneM;
balance[selectId] = balanceM;
}
// -----------------------------------------DeleteMethod----------------------------------------------
public void deleteMember(int id) {
int pos = id;
personId[pos] = 0;
password[pos] = null;
citizen_id[pos] = null;
member_name[pos] = null;
address[pos] = null;
email[pos] = null;
telephone[pos] = null;
balance[pos] = 0;
// limit--;
}
// -------------------------------------------Operation------------------------------------------------
public void buyProduct(int id, int total) {
balance[id] -= total;
}
public static void topup(int id, int total) {
balance[id] += total;
}
}