-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
663 lines (517 loc) · 21.9 KB
/
index.html
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8" />
<title>Prog I · Uenp Steam</title>
<link rel="icon" type="image/svg" href="./public/favicon.svg" />
<meta
name="description"
content="Apresentation for final work in Prog I at UENP - created with Reveal.js"
/>
<meta name="author" content="Henrique GC" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="dist/reset.css" />
<link rel="stylesheet" href="dist/reveal.css" />
<link rel="stylesheet" href="dist/theme/black.css" id="theme" />
<!-- syntax highlighting of code -->
<link rel="stylesheet" href="plugin/highlight/monokai.css" />
</head>
<body>
<div class="reveal">
<div class="slides">
<!--Data struct-->
<section data-auto-animate>
<p>Estrutura de dado - Jogo</p>
<pre data-id="code-animation">
<code class="hljs c" data-trim data-line-numbers>
<script type="text/template">
struct Game {
char name[20];
char platform[30];
char type[30];
float price;
float rating;
int year;
char producer[30];
int classification;
};
</script>
</code>
</pre>
</section>
<!--Function 1: Create Register-->
<section data-auto-animate>
<h3 data-id="code-title">Funções</h3>
<p>Criar Registro</p>
<pre data-id="code-animation">
<code class="hljs c"
data-trim data-line-numbers="1|2-8|10-18|41|43"
>
<script type="text/template">
int createRegister(FILE *f, char *filename) {
f = fopen(filename, "ab");
if (f == NULL) {
printf("arquivo não pode ser aberto... encerrando\n");
return 2;
}
struct Game g;
printf("******************************\n");
printf("*** CADASTRAR UM NOVO JOGO ***\n");
printf("******************************\n\n");
setbuf(stdin, 0);
printf("nome: ");
fgets(g.name, sizeof(g.name), stdin);
printf("tipo: ");
fgets(g.type, sizeof(g.type), stdin);
printf("plataforma: ");
fgets(g.platform, sizeof(g.platform), stdin);
printf("produtora: ");
fgets(g.producer, sizeof(g.producer), stdin);
printf("ano: ");
scanf("%d", &g.year);
printf("preço: ");
scanf("%f", &g.price);
printf("rating: ");
scanf("%f", &g.rating);
printf("atual classification: ");
scanf("%d", &g.classification);
fwrite(g, sizeof(struct Game), 1, f);
fclose(f);
return 0;
}
</script>
</code>
</pre>
</section>
<!--Function 2: Ler todos os registros-->
<section data-auto-animate>
<h3 data-id="code-title">Funções</h3>
<p>Ler Todos os Registro</p>
<pre data-id="code-animation">
<code class="hljs c"
data-trim data-line-numbers="1|2-8|10-16|17-26|29"
>
<script type="text/template">
int readAllRegisters(FILE *f, char *filename) {
f = fopen(filename, "rb");
if (f == NULL) {
printf("arquivo nao pode ser aberto... encerrando\n");
return 3;
}
printf("******************************\n");
printf("**** LISTAR TODOS OS JOGOS****\n");
printf("******************************\n\n");
struct Game data;
while (fread(&data, sizeof(struct Game), 1, f)) {
printf("nome: %s", data.name);
printf("plataforma: %s", data.platform);
printf("tipo: %s", data.type);
printf("produtora: %s", data.producer);
printf("preço: %f\n", data.price);
printf("rating: %f\n", data.rating);
printf("ano: %d\n", data.year);
printf("classificação: %d\n", data.classification);
printf("\n");
}
fclose(f);
return 0;
}
</script>
</code>
</pre>
</section>
<!--Function 3: Ler um dos registros-->
<section>
<section data-auto-animate>
<h3 data-id="code-title">Funções</h3>
<p>Ler Um dos Registros</p>
<pre data-id="code-animation">
<code class="hljs c"
data-trim data-line-numbers="1|2-8|10-19|21-25"
>
<script type="text/template">
int readOneRegister(FILE *f, char *filename) {
f = fopen(filename, "rb");
if (f == NULL) {
printf("arquivo não pode ser aberto.. encerrando\n");
return 4;
}
printf("******************************\n");
printf("***** LISTAR UM DOS JOGOS*****\n");
printf("******************************\n\n");
struct Game data;
char gameName[sizeof(data.name)];
setbuf(stdin, 0);
printf("Digite o nome que deseja procurar: ");
fgets(gameName, sizeof(gameName), stdin);
int is_register = verify_register(data, gameName, f);
if (!is_register) {
printf("registro não encontrado...\n");
}
fclose(f);
return 0;
}
</script>
</code>
</pre>
</section>
<!--Funcão 3: regra de negócio-->
<section data-auto-animate>
<h3 data-id="code-title">Ler um Registro</h3>
<p>Regra de Negócio</p>
<pre data-id="code-animation">
<code class="hljs c"
data-trim data-line-numbers="1|2|3-14|16"
>
<script type="text/template">
int verify_register(struct Game data, char *game, FILE *f) {
while (fread(&data, sizeof(struct Game), 1, f)) {
if (!strcmp(data.name, game)) {
printf("nome: %s", data.name);
printf("plataforma: %s", data.platform);
printf("tipo: %s", data.type);
printf("produtora: %s", data.producer);
printf("preço: %f\n", data.price);
printf("rating: %f\n", data.rating);
printf("ano: %d\n", data.year);
printf("classificação: %d\n", data.classification);
return 1;
}
return 0;
}
</script>
</code>
</pre>
</section>
</section>
<!--Function 4: Modificar um dos registros-->
<section>
<section data-auto-animate>
<h3 data-id="code-title">Funções</h3>
<p>Modificar Um dos Registros</p>
<pre data-id="code-animation">
<code class="hljs c"
data-trim data-line-numbers="1|2-8|10-19|21-25"
>
<script type="text/template">
int modifyOneRegister(FILE *f, char *filename) {
f = fopen(filename, "rb+");
if (f == NULL) {
printf("arquivo não pode ser aberto.. encerrando\n");
return 5;
}
printf("******************************\n");
printf("*** MODIFICAR UM DOS JOGOS ***\n");
printf("******************************\n\n");
struct Game data;
char gameName[sizeof(data.name)];
setbuf(stdin, 0);
printf("Digite o nome que deseja procurar: ");
fgets(gameName, sizeof(gameName), stdin);
int is_register = verify_register_to_update(data, gameName, f);
if (!is_register) {
printf("registro não encontrado...\n");
}
fclose(f);
return 0;
}
</script>
</code>
</pre>
</section>
<!--Funcão 4: regra de negócio-->
<section data-auto-animate>
<h3 data-id="code-title">Modificar um Registro</h3>
<p>Regra de Negócio</p>
<pre data-id="code-animation">
<code class="hljs c"
data-trim data-line-numbers="1|2-10|12-19|23|24|26-29|31-42|95-104|148|149|153|157"
>
<script type="text/template">
int verify_register_to_update(struct Game data, char *game, FILE *f) {
// confirmation - 0 or 1
int modifyName;
int modifyProducer;
int modifyPlataform;
int modifyType;
int modifyYear;
int modifyPrice;
int modifyRating;
int modifyClassification;
char newName[sizeof(data.name)];
char newProducer[sizeof(data.producer)];
char newPlataform[sizeof(data.platform)];
char newType[sizeof(data.type)];
int newYear;
float newPrice;
float newRating;
int newClassification;
int registerCount = 0;
while (fread(&data, sizeof(struct Game), 1, f)) {
long int pos = ftell(f);
if (!strcmp(data.name, game)) {
registerCount++;
printf("\nalterando registro [%d]\n", registerCount);
printf("Deseja alterar o nome? [1 - yes / 0 - no]: ");
scanf("%d", &modifyName);
if (modifyName) {
setbuf(stdin, 0);
printf("Digite o novo nome: ");
fgets(newName, sizeof(newName), stdin);
for (int i = 0; i < sizeof(data.name); i++) {
data.name[i] = newName[i];
}
}
setbuf(stdin, 0);
printf("\n");
printf("Deseja alterar a produtora? [1 - yes / 0 - no]: ");
scanf("%d", &modifyProducer);
if (modifyProducer) {
setbuf(stdin, 0);
printf("Digite a nova produtora: ");
fgets(newProducer, sizeof(newProducer), stdin);
for (int i = 0; i < sizeof(data.producer); i++) {
data.producer[i] = newProducer[i];
}
}
setbuf(stdin, 0);
printf("\n");
printf("Deseja alterar a plataforma? [1 - yes / 0 - no]: ");
scanf("%d", &modifyPlataform);
if (modifyPlataform) {
setbuf(stdin, 0);
printf("Digite a nova plataforma: ");
fgets(newPlataform, sizeof(newPlataform), stdin);
for (int i = 0; i < sizeof(data.platform); i++) {
data.platform[i] = newPlataform[i];
}
}
setbuf(stdin, 0);
printf("\n");
printf("Deseja alterar o tipo? [1 - yes / 0 - no]: ");
scanf("%d", &modifyType);
if (modifyType) {
setbuf(stdin, 0);
printf("Digite o novo tipo: ");
fgets(newType, sizeof(newType), stdin);
for (int i = 0; i < sizeof(data.type); i++) {
data.type[i] = newType[i];
}
}
setbuf(stdin, 0);
printf("\n");
printf("Deseja alterar o ano? [1 - yes / 0 - no]: ");
scanf("%d", &modifyYear);
if (modifyYear) {
setbuf(stdin, 0);
printf("Digite o novo ano: ");
scanf("%d", &newYear);
data.year = newYear;
}
setbuf(stdin, 0);
printf("\n");
printf("Deseja alterar o preço? [1 - yes / 0 - no]: ");
scanf("%d", &modifyPrice);
if (modifyPrice) {
setbuf(stdin, 0);
printf("Digite o novo preço: ");
scanf("%f", &newPrice);
data.price = newPrice;
}
setbuf(stdin, 0);
printf("\n");
printf("Deseja alterar a classificação? [1 - yes / 0 - no]: ");
scanf("%d", &modifyClassification);
if (modifyClassification) {
setbuf(stdin, 0);
printf("Digite a nova classificação: ");
scanf("%d", &newClassification);
data.classification = newClassification;
}
setbuf(stdin, 0);
printf("\n");
printf("Deseja alterar o rating? [1 - yes / 0 - no]: ");
scanf("%d", &modifyRating);
if (modifyRating) {
setbuf(stdin, 0);
printf("Digite o novo rating: ");
scanf("%f", &newRating);
data.rating = newRating;
}
fseek(f, pos - sizeof(struct Game), SEEK_SET);
fwrite(&data, sizeof(struct Game), 1, f);
printf("registro alterado com sucesso!\n");
return 1;
}
}
return 0;
}
</script>
</code>
</pre>
</section>
</section>
<!--Function 5: Remover um dos registros-->
<section data-auto-animate>
<h3 data-id="code-title">Funções</h3>
<p>Remover Um dos Registro</p>
<pre data-id="code-animation">
<code class="hljs c"
data-trim data-line-numbers="1-6|8-18|20-29|31-43|45-54|56-62|64-65|67-68"
>
<script type="text/template">
int deleteOneRegister(FILE *f, char *filename) {
f = fopen(filename, "rb+");
remove("swapDatabase.bin");
char *swapFilename = "swapDatabase.bin";
FILE *swapF = fopen(swapFilename, "ab");
if (swapF == NULL) {
printf("arquivo de troca não pode ser aberto.. encerrando\n");
return 5;
}
if (f == NULL) {
printf("arquivo não pode ser aberto.. encerrando\n");
return 5;
}
struct Game game;
char gameName[sizeof(game.name)];
printf("******************************\n");
printf("**** DELETAR UM DOS JOGOS ****\n");
printf("******************************\n\n");
setbuf(stdin, 0);
printf("Digite o nome que deseja procurar: ");
fgets(gameName, sizeof(gameName), stdin);
int found = 0;
while (fread(&game, sizeof(struct Game), 1, f)) {
if (!strcmp(game.name, gameName)) {
found = 1;
}
}
if (!found) {
printf("registro não encontrado... encerrando\n");
return 1;
}
int confirmation = 0;
printf("deseja mesmo remover o registro? [1 - yes / 0 - no]: ");
scanf("%d", &confirmation);
if (!confirmation) {
printf("registro não removido com sucesso!\n");
return 0;
}
while (fread(&game, sizeof(struct Game), 1, f)) {
if (strcmp(game.name, gameName)) {
fwrite(&game, sizeof(struct Game), 1, swapF);
}
}
printf("registro removido com sucesso!\n");
fclose(f);
fclose(swapF);
remove(filename);
rename(swapFilename, filename);
return 0;
}
</script>
</code>
</pre>
</section>
<!--Main: Lógica-->
<section data-auto-animate>
<p>Lógica da aplicação</p>
<pre data-id="code-animation">
<code class="hljs c"
data-trim data-line-numbers="2-8|10-11|13-18|20|21|23-30|32-42|77-81|83|20|86"
>
<script type="text/template">
int main(int argc, char **argv) {
char *filename = argv[1];
if (filename == NULL) {
printf("database não foi fornecida... encerrando\n");
return 1;
}
FILE *fptr_i;
FILE *fptr;
int userContinue = 1;
int userCreateRegister = 0;
int userListAllRegisters = 0;
int userListOneRegister = 0;
int userUpdateOneRegister = 0;
int userDeleteOneRegister = 0;
while (userContinue != 0) {
greeting(fptr_i, "image.txt");
printf("deseja criar um usuário? [1 - y / 0 - no]: ");
scanf("%d", &userCreateRegister);
if (userCreateRegister) {
clearScreen();
createRegister(fptr, filename);
}
setbuf(stdin, 0);
printf("\n");
printf("deseja listar todos os usuários? [1 - y / 0 - no]: ");
scanf("%d", &userListAllRegisters);
if (userListAllRegisters) {
clearScreen();
readAllRegisters(fptr, filename);
}
setbuf(stdin, 0);
printf("\n");
printf("deseja listar um usuário? [1 - y / 0 - no]: ");
scanf("%d", &userListOneRegister);
if (userListOneRegister) {
clearScreen();
readOneRegister(fptr, filename);
}
setbuf(stdin, 0);
printf("\n");
printf("deseja atualizar um usuário? [1 - y / 0 - no]: ");
scanf("%d", &userUpdateOneRegister);
if (userUpdateOneRegister) {
clearScreen();
modifyOneRegister(fptr, filename);
}
setbuf(stdin, 0);
printf("\n");
printf("deseja remover um usuário? [1 - y / 0 - no]: ");
scanf("%d", &userDeleteOneRegister);
if (userDeleteOneRegister) {
clearScreen();
deleteOneRegister(fptr, filename);
}
setbuf(stdin, 0);
printf("\n");
printf("deseja continuar no programa? [1 - y / 0 - no]: ");
scanf("%d", &userContinue);
clearScreen();
}
return 0;
}
</script>
</code>
</pre>
</section>
<!--Video example-->
<section>
<h3 data-id="code-title">Exemplo</h3>
<video controls src="./public/video_example.mp4"></video>
</section>
</div>
</div>
<script src="dist/reveal.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
Reveal.initialize({
keyboard: true,
overview: true,
controls: true,
center: true,
hash: true,
progress: false,
plugins: [RevealHighlight],
});
</script>
</body>
</html>