-
Notifications
You must be signed in to change notification settings - Fork 1
/
tubes.cpp
68 lines (63 loc) · 1.37 KB
/
tubes.cpp
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
#include "tubes.h"
adruser alokasiUser(int id, string username, string password){
adruser p = new ElmUser;
p->username = username;
p->password = password;
p->iduser = id;
p->next = NULL;
p->status = NULL;
return p;
};
adrstatus alokasiStatus(int id, string info){
adrstatus p = new ElmStatus;
p->idstatus = id;
p->info = info;
p->like = 0;
p->tag = NULL;
p->next = NULL;
return p;
};
adrtag alokasiTag(int id){
adrtag p = new ElmTag;
p->iduser = id;
p->next = NULL;
return p;
};
void add_user(socmed &s, adruser userbaru){
if (userexist(s,userbaru->username)){ //cek jika user sudah ada
cout << "User sudah ada!";
}
else {
if (s.first==NULL){ //jika list user masih kosong
s.first = userbaru;
}
else {
userbaru->next = s.first;
s.first = userbaru;
}
}
};
bool userexist(socmed s, string u_name){
adruser p = s.first;
adruser revalue;
if (p==NULL){
revalue = NULL;
}
else {
while (p!=NULL){
if (u_name==p->username){
break;
}
else {
p = p->next;
}
}
revalue = p;
}
if (revalue!=NULL){
return true;
}
else {
return false;
}
};