-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMLL.cpp
More file actions
250 lines (235 loc) · 6.9 KB
/
MLL.cpp
File metadata and controls
250 lines (235 loc) · 6.9 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#include "MLL.hpp"
#include <iostream>
using namespace std;
void create_List(List &ListChild) {
first(ListChild) = nil;
}
void newElm_Parent(parent info, adrParent &S) {
S = new elmParent;
info(S) = info;
next(S) = nil;
nextChild(S) = nil;
}
void newElm_Child(infotypeCh info, adrChild &J) {
J = new elmChild;
info(J) = info;
next(J) = nil;
}
void insertNew_Child(List &ListParent, adrParent S, adrChild J) {
if(nextChild(S) == nil) {
nextChild(S) = J;
} else {
adrChild P = nextChild(S);
while (next(P) != nil) {
P = next(P);
}
next(P) = J;
}
}
void inserLast_Parent(List &ListParent, adrParent S) {
if(first(ListParent) == nil) {
first(ListParent) = S;
} else {
adrParent P = first(ListParent);
while (next(P) != nil) {
P = next(P);
}
next(P) = S;
}
}
void deleteFirst_Child(List &ListParent, adrParent &S, adrChild &J) {
adrChild P = nextChild(S);
J = nextChild(S);
if(next(P) == nil) {
nextChild(S) = nil;
} else {
nextChild(S) = next(P);
next(P) = nil;
}
}
void deleteLast_Child(List &ListChild, adrParent &S, adrChild &J) {
}
void deleteAfter_Child(List &ListChild, adrChild Prec, adrChild &J) {
J = next(Prec);
next(Prec) = next(J);
next(J) = nil;
}
adrChild searchBefore_Child(List ListParent, string number, string ID) {
adrParent P = first(ListParent);
while (P != nil) {
if(info(P).nomor_KK == number) {
adrChild Q = next(nextChild(P));
adrChild R = nextChild(P);
while (next(Q) != nil) {
if(info(Q).nik == ID) {
return R;
}
R = Q;
Q = next(Q);
}
return R;
}
P = next(P);
}
return 0;
}
void deleteFirst_Parent(List &ListParent) {
adrParent P;
if(first(ListParent) == nil) {
cout << "List Kosong\n";
} else {
P = first(ListParent);
first(ListParent) = next(P);
next(P) = nil;
}
}
void deleteAfter_Parent(adrParent Prec, adrParent P) {
P = next(Prec);
next(Prec) = next(P);
next(P) = nil;
}
adrParent searchBefore_Parent(List ListParent, string number) {
adrParent P = next(first(ListParent));
adrParent Q = first(ListParent);
while (next(P) == nil) {
if(info(P).nomor_KK == number) {
return Q;
}
Q = P;
P = next(P);
}
return Q;
return 0;
}
void showData_Parent(List ListParent) {
int i;
i = 1;
if(first(ListParent) == nil) {
cout << "List Kosong\n";
} else {
adrParent P = first(ListParent);
while (P != nil) {
adrChild Q;
Q = nextChild(P);
cout << i << ". "<< info(P).nomor_KK << endl;
i++;
P = next(P);
}
}
}
void showData_Child(List ListParent) {
string input;
int i = 1;
if (first(ListParent) == NULL) {
cout << "LIST KOSONG" << endl<<endl;
} else {
adrParent P = first(ListParent);
cout << "List nomor kartu keluarga :" << endl;
while (P != NULL){
cout << i << ". "<< info(P).nomor_KK << endl;
i++;
P = next(P);
}
cout << "Masukkan Nomor Kartu Keluarga Yang Ingin Di Tampilkan : ";
cin >> input;
P = first(ListParent);
while (P != NULL){
adrChild Q = nextChild(P);
if (info(P).nomor_KK == input){
while(Q != NULL){
cout << "Nama lengkap : " << info(Q).nama_Lengkap << endl;
cout << "NIK : " << info(Q).nik << endl;
cout << "Tanggal lahir : " << info(Q).tanggal_Lahir << endl;
cout << "Tempat lahir : " << info(Q).tempat_Lahir << endl;
cout << "Status : " << info(Q).status << endl;
cout << endl;
Q = next(Q);
}
}
P = next(P);
}
}
}
adrParent search_Parent(List ListChild, string number) {
adrParent P = first(ListChild);
while (P != NULL) {
if (info(P).nomor_KK == number){
return P;
}
P = next(P);
}
return nil;
return 0;
}
void cari_Child(List ListParent, string nik) {
adrParent P = first(ListParent);
adrChild C = search_Child(ListParent, nik);
if (first(ListParent) == NULL){
cout << "==================================" << endl;
cout << "| Nomor Induk Keluarga Tidak Di temukan |" << endl;
cout << "==================================" << endl;
}else if(P != NULL){
P = first(ListParent);
while(P != NULL){
adrChild Q = nextChild(P);
while(Q != NULL){
if (info(Q).nik == nik && C != NULL){
if(C != NULL){
cout << "==================================" << endl;
cout << "Nama lengkap : " << info(Q).nama_Lengkap << endl;
cout << "NIK : " << info(Q).nik << endl;
cout << "Tanggal lahir : " << info(Q).tanggal_Lahir << endl;
cout << "Tempat lahir : " << info(Q).tempat_Lahir << endl;
cout << "Status : " << info(Q).status << endl;
cout << "==================================" << endl;
}
} else if(C == NULL) {
cout << "==================================" << endl;
cout << "| Nomor Induk Keluarga Mahasiswa Tidak Di Temukan |" << endl;
cout << "==================================" << endl;
}
cout << endl;
Q = next(Q);
}
P = next(P);
}
}
}
adrChild search_Child(List ListParent, string nik) {
adrParent P = first(ListParent);
while (P != NULL) {
adrChild Q = nextChild(P);
while(Q != NULL){
if (info(Q).nik == nik){
return Q;
}
Q = next(Q);
}
P = next(P);
}
return nil;
return 0;
}
int selectMenu() {
cout << "============================\n";
cout << " ---------------------- \n";
cout << " PROGRAM KARTU KELUARGA \n";
cout << " ---------------------- \n";
cout << " Ahmad Naufal Diwantara Putra 1302204085 \n";
cout << " Jeremia Carlo Christianto Silitonga 1302204115 \n";
cout << "============================\n";
cout << "1. Tambah Daftar Keluarga\n";
cout << "2. Tambah Anggota Keluarga\n";
cout << "3. Menampilkan Daftar Keluarga\n";
cout << "4. Menampilkan anggota keluarga\n";
cout << "5. Delete anggota keluarga\n";
cout << "6. Delete Anggota Keluarga\n";
cout << "7. Cari Child\n";
cout << "0. Keluar" << endl << endl;
cout << "Pilihan menu : " ;
int input;
cin >> input;
cout << endl;
return input;
return 0;
}