Newer
Older
#include "datastructure.h"
#include "cds.h"
#include "tools.h"
#include "datetime.h"
#include "sort.h"
#include "menu.h"
#define NUMBER_OF_MENU_ITEMS 8
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
sCD CDData[MAXCDS];
void createCD()
{
if (countCDs == MAXCDS)
{
puts("Maximum number of cds reached!");
exit(0);
}
clearScreen();
puts("Erfassung einer neuen CD");
printLine('=', 50);
(CDData + countCDs)->numberOfSongs = 0;
getText("Geben Sie bitte den Titel der CD ein:", 35, &(CDData + countCDs)->title, 0);
getText("Geben Sie bitte den Interpreten ein:", 35, &(CDData + countCDs)->artist, 1);
getNumber("Geben Sie bitte das Erscheinungsjahr ein:", &(CDData + countCDs)->publicationYear, 1982, 2022);
puts("Geben Sie bitte die Daten der Lieder ein:");
creatSong();
countCDs++;
}
void creatSong()
{
do
{
printf("Lied %i:\n", ((CDData + countCDs)->numberOfSongs) + 1);
getText("Geben Sie bitte den Titel des Liedes ein:", 35, &(CDData + countCDs)->Songs[(CDData + countCDs)->numberOfSongs].title, 0);
getText("Geben Sie bitte den Interpreten ein:", 35, &(CDData + countCDs)->Songs[(CDData + countCDs)->numberOfSongs].artist, 1);
inputTime("Geben Sie bitte die Dauer des Liedes ein\n (Format hh:mm:ss oder mm:ss):\n -> ", &(CDData + countCDs)->Songs[(CDData + countCDs)->numberOfSongs].duration);
(CDData + countCDs)->numberOfSongs++;
} while ((askYesOrNo("Moechten Sie noch ein weiteres Lied eingeben (j/n)?")) && ((CDData + countCDs)->numberOfSongs) < MAXSONGS);
}
void editCd()
{
puts("editCd");
waitForEnter();
}
void deleteCD()
{
puts("deleteCd");
waitForEnter();
}
void searchSong()
{
puts("deleteCd");
waitForEnter();
}
void sortCDs()
{
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
int choice;
char *menuTitle = "CDs sortieren";
char *menuItems[] = {"Sortieren nach CD-Titel", "Sortieren nach CD-Interpret", "Sortieren nach Erscheinungsjahr",
"Sortieren nach Anzahl Lieder", "Sortieren nach Song-Titel", "Sortieren nach Song-Interpret", "Sortieren nach Song-Duration", "Zurueck zum Hauptmenue"};
choice = getMenu(menuTitle, menuItems, NUMBER_OF_MENU_ITEMS);
switch (choice)
{
case 1:
quickSort(0, countCDs - 1, stringSort, 0);
puts("°Sorrting has been suceffully done ..... ok!");
waitForEnter();
break;
case 2:
quickSort(0, countCDs - 1, stringSort, 1);
puts("°Sorrting has been suceffully done ..... ok!");
waitForEnter();
break;
case 3:
quickSort(0, countCDs - 1, numSort, 2);
puts("°Sorrting has been suceffully done ..... ok!");
waitForEnter();
break;
case 4:
quickSort(0, countCDs - 1, numSort, 3);
puts("°Sorrting has been suceffully done ..... ok!");
waitForEnter();
break;
case 5:
for (int i = 0; i < countCDs; i++)
{
quickSort1(0, (CDData + i)->numberOfSongs - 1, stringSort, 1, i);
}
puts("°Sorrting has been suceffully done ..... ok!");
waitForEnter();
break;
case 6:
for (int i = 0; i < countCDs; i++)
{
quickSort1(0, (CDData + i)->numberOfSongs - 1, stringSort, 0, i);
}
puts("°Sorrting has been suceffully done ..... ok!");
waitForEnter();
break;
case 7:
for (int i = 0; i < countCDs; i++)
{
quickSort1(0, (CDData + i)->numberOfSongs - 1, numSort, 2, i);
}
puts("°Sorrting has been suceffully done ..... ok!");
waitForEnter();
break;
case 8:
puts("Press Enter to get back to the main menue ..!");
waitForEnter();
break;
default:
waitForEnter();
break;
}
int gesamtLaufZeit = 0;
if (countCDs == 0)
{
puts("No song created or loaded yet!, you need first of all to load or creat at least one song to be able to see the listed itmes!");
waitForEnter();
}
{
putchar('\n');
printf("Titel : %s\n", (CDData + i)->title);
if ((CDData + i)->artist)
printf("artist : %s\n", (CDData + i)->artist);
printf("Erscheinungsjahr : %i\n", (CDData + i)->publicationYear);
printf("Anzahl Lieder : %i\n", (CDData + i)->numberOfSongs);
puts("Lieder");
gesamtLaufZeit += durationConverter((CDData + i)->Songs[j].duration);
if ((CDData + i)->Songs[j].artist)
{
printf("%.1i. %s (%s; ", (j + 1), (CDData + i)->Songs[j].title, (CDData + i)->Songs[j].artist);
printTime((CDData + i)->Songs[j].duration, 1);
puts(")");
}