-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathjukebox.c
132 lines (118 loc) · 3.68 KB
/
jukebox.c
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
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct musics {
char brand[12];
int vol;
char brand_message[100];
};
char * easter_egg = "d8dae94c2028d44c6cfe7834348df6659096102c3412988ebc1ff033bdbfb319";
void change_vinyl(struct musics * musics_obj) {
int length = strlen(musics_obj->brand);
printf("Please enter vinyl to change to: ");
fread(musics_obj->brand, length, 1, stdin);
printf("Musical brand changed to: %s\n", musics_obj->brand);
}
void change_volumes(struct musics * musics_obj) {
--musics_obj->vol;
printf("Changed volume. Current level: %d\n", musics_obj->vol);
}
void make_louder(struct musics * musics_obj) {
++musics_obj->vol;
printf("Much louder\n");
}
void do_getdown(struct musics * musics_obj) {
printf("And now a message from our sponsors:\n");
printf(musics_obj->brand_message);
puts("\n");
if (musics_obj->vol) {
printf("Sorry, you're not allowed to do the get down unless its quiet\n");
}
else {
puts("Ohhhhhhh you got it alllll the way down;ed");
exit(0);
}
}
void musics_simulator() {
// Zero the diaper struct
struct musics musics_profile;
memset(&musics_profile, 0, sizeof(musics_profile));
// Display a list of diaper brands to set
printf("Pick a brand:\n");
printf("1. Eargasms\n");
printf("2. Sunny\n");
printf("3. Follow Rabbit\n");
printf("4. Memememe\n");
printf("5. Chilled ZZZZ\n");
printf("> ");
// Get number from user
int choice = 0;
scanf("%d", &choice);
// Check that number is within the range
if (choice <= 0 || choice > 5) {
printf("Invalid Musics brand\n");
exit(1);
}
// Initialise the diapers with the parameters
switch(choice) {
case 1:
memcpy(musics_profile.brand, "Eargasms", 8);
strcpy(musics_profile.brand_message, "Happy ears!");
break;
case 2:
memcpy(musics_profile.brand, "Sun", 3);
strcpy(musics_profile.brand_message, "Sunshines and sparkles");
break;
case 3:
memcpy(musics_profile.brand, "Follow Rabbit", 12);
strcpy(musics_profile.brand_message, "One pill will make you smarter, one pill makes you tall. Ask Alice. When she's ten feet tall.");
break;
case 4:
memcpy(musics_profile.brand, "Memememe", 8);
strcpy(musics_profile.brand_message, "Best songs of your life!");
break;
case 5:
memcpy(musics_profile.brand, "Chilled ZZZZ", 12);
strcpy(musics_profile.brand_message, "zz");
break;
}
musics_profile.vol = 256; // Wetness
char cont = 1;
while (cont) {
if (musics_profile.vol) {
printf("The volume's too loud!!!\n");
}
else {
printf("Silence is the best..\n");
}
printf("0) Change Vinyl\n");
printf("1) Lower Z Volume\n");
printf("2) Leave\n");
printf("> ");
scanf("%d", &choice);
switch(choice) {
case 0:
change_vinyl(&musics_profile);
break;
case 1:
change_volumes(&musics_profile);
break;
case 2:
do_getdown(&musics_profile);
break;
case 42:
make_louder(&musics_profile);
break;
default:
printf("Invalid choice\n");
break;
}
choice = -1;
}
}
int main() {
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
puts("Welcome to the Mystery Jukebox Machine\n");
musics_simulator();
}