-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriting.cpp
More file actions
121 lines (114 loc) · 3.65 KB
/
writing.cpp
File metadata and controls
121 lines (114 loc) · 3.65 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
#include "header.h"
using namespace std;
void createListWriting(ListW &W) {
firstWriting(W) = NULL;
}
adrWriting createElmWriting(adrBlogger b, adrPlatform p){
adrWriting w = new writing;
infoBlogger(w) = b;
infoPlatform(w) = p;
nextWriting(w) = NULL;
return w;
}
void addWriting(ListW &W, adrBlogger b, adrPlatform p){
adrWriting w = createElmWriting(b, p), temp;
bool checkW = findWriting(W, b, p);
if (checkW == false) {
if (firstWriting(W) != NULL) {
temp = firstWriting(W);
while (nextWriting(temp) != NULL) {
temp = nextWriting(temp);
}
nextWriting(temp) = w;
} else {
firstWriting(W) = w;
}
} else {
cout << "Platform " << namaPlatform(p) << " sudah digunakan oleh Blogger " << namaBlogger(b) << endl;
}
}
bool findWriting(ListW W, adrBlogger b, adrPlatform p){
bool s = false;
adrWriting temp = firstWriting(W);
while (temp != NULL) {
if (infoBlogger(temp) == b && infoPlatform(temp) == p){
s = true;
}
temp = nextWriting(temp);
}
return s;
}
void printAll(ListW W, ListB B) {
adrBlogger b = firstBlogger(B);
adrPlatform p;
cout << "------------------------------------" << endl;
cout << "| Blogger dan Platform |" << endl;
cout << "------------------------------------" << endl;
if (firstBlogger(B) != NULL) {
while (b != NULL) {
cout << "Kode Blogger : " << kodePenulis(b) << endl;
cout << "Nama Blogger : " << namaBlogger(b) << endl;
cout << "Email Blogger : " << emailBlogger(b) << endl << endl;
cout << "Menulis di Platform : " << endl;
adrWriting w = firstWriting(W);
while (w != NULL) {
if (infoBlogger(w) == b) {
p = infoPlatform(w);
cout << "Nama Platform : " << namaPlatform(p) << endl;
cout << "Url Platform : " << urlPlatform(p) << endl;
cout << "------------------------------------" << endl;
}
w = nextWriting(w);
}
cout << "------------------------------------" << endl;
b = nextBlogger(b);
}
} else {
cout << "Blogger tidak ada!" << endl;
}
cout << "Tekan sembarang tombol...";
getch();
}
void delBlogWriting(ListW &W, ListP &P, adrBlogger b) {
adrWriting w = firstWriting(W);
adrPlatform p;
while (w != NULL) {
if (infoBlogger(w) == b) {
p = infoPlatform(w);
delWriting(W, w);
bool found = false;
adrWriting checkw = firstWriting(W);
while (checkw != NULL) {
if (infoPlatform(checkw) == p) {
found = true;
}
checkw = nextWriting(checkw);
}
if (found == false) {
delPlatform(P, p);
}
}
w = nextWriting(w);
}
}
void delWriting(ListW &W, adrWriting w) {
adrWriting del,temp = firstWriting(W);
if (w == firstWriting(W)) {
del = firstWriting(W);
firstWriting(W) = nextWriting(del);
nextWriting(del) = NULL;
} else if (nextWriting(w) == NULL) {
while (nextWriting(nextWriting(temp)) != NULL) {
temp = nextWriting(temp);
}
del = nextWriting(temp);
nextWriting(temp) = NULL;
} else {
while (nextWriting(temp) != w) {
temp = nextWriting(temp);
}
del = nextWriting(temp);
nextWriting(temp) = nextWriting(del);
nextWriting(del) = NULL;
}
}