-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparent.cpp
More file actions
115 lines (105 loc) · 2.25 KB
/
parent.cpp
File metadata and controls
115 lines (105 loc) · 2.25 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
#include "parent.h"
void createListgames(listgames &L){
first(L)=NULL;
/* Muhammad Ghifari Adrian
1301194034
IF-43-05
*/
}
g_address creategames(infotypeG info){
g_address P;
P=new games;
info(P)=info;
info(P).users=0;
next(P)=NULL;
return P;
/* Muhammad Ghifari Adrian
1301194034
IF-43-05
*/
}
void insertgames(g_address &P, listgames &L){
g_address G;
G=searchgames((info(P)).id,L);
if(G==NULL){
if(first(L)==NULL){
first(L)=P;
}else{
next(P)=first(L);
first(L)=P;
}
}else{
cout << "Duplication ID Detected" << endl;
cout << "Deallocate Game" << endl;
delete P;
P=NULL;
}
/* Muhammad Ghifari Adrian
1301194034
IF-43-05
*/
}
void deletegames(g_address &P,listgames &L){
g_address Q=first(L);
if(P!=NULL){
if(P==first(L)&&next(P)==NULL){
first(L)=NULL;
cout << "List menjadi kosong!" << endl;
}else if(P==first(L)){
first(L)=next(P);
next(P)=NULL;
}else{
while(Q!=NULL&&next(Q)!=P){
Q=next(Q);
}
if(Q!=NULL){
next(Q)=next(P);
next(P)=NULL;
}
}
cout << "Game telah dihapus" << endl;
delete P;
P=NULL;
}else{
cout << "Game tidak ditemukan" << endl;
}
/* Muhammad Ghifari Adrian
1301194034
IF-43-05
*/
}
g_address searchgames (string kode,listgames &L){
g_address P=first(L);
while(P!=NULL&&info(P).nama!=kode&&info(P).id!=kode){
P=next(P);
}
return P;
/* Muhammad Ghifari Adrian
1301194034
IF-43-05
*/
}
void showGames(g_address P){
cout << "Nama Games\t: " << info(P).nama <<endl;
cout << "ID Games\t: " << info(P).id <<endl;
cout << "Jumlah pemain\t: " << info(P).users <<endl;
cout << "Harga Games\t: " << info(P).harga << endl;
/* Muhammad Ghifari Adrian
1301194034
IF-43-05
*/
}
void showAllGames(listgames L){
int i=1;
g_address P=first(L);
while(P!=NULL){
cout << i <<endl;
showGames(P);
i++;
P=next(P);
}
/* Muhammad Ghifari Adrian
1301194034
IF-43-05
*/
}