-
Notifications
You must be signed in to change notification settings - Fork 0
/
tampilan.c
333 lines (301 loc) · 11.4 KB
/
tampilan.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
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
/**
* Program file name : tampilan.c
* Description : definisi prototipe modul-modul behavior untuk tampilan pada Kakuraato.
* Author : Danu Mahesa, 211524037
* Compiler : GCC
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <windows.h>
#include "tampilan.h"
int getScreenWidth() {
CONSOLE_SCREEN_BUFFER_INFOEX _infoex = {0};
HANDLE handleOfConsoleOutput = NULL;
handleOfConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
_infoex.cbSize = sizeof(_infoex);
GetConsoleScreenBufferInfoEx(handleOfConsoleOutput, &_infoex);
return _infoex.srWindow.Right;
}
int getScreenHeight() {
CONSOLE_SCREEN_BUFFER_INFOEX _infoex = {0};
HANDLE handleOfConsoleOutput = NULL;
handleOfConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
_infoex.cbSize = sizeof(_infoex);
GetConsoleScreenBufferInfoEx(handleOfConsoleOutput, &_infoex);
return _infoex.srWindow.Bottom;
}
void tampilMainMenu(){
int widthOfScreen = getScreenWidth();
int heightOfScreen = getScreenHeight();
int _X = widthOfScreen / 2 - 31;
int _Y = heightOfScreen / 2 - 9;
gotoxy(_X - 8, _Y - 3);
printf("=====================================================================================\n");
printBanner();
printf("\n\n");
gotoxy(_X - 8, _Y + 10);
printf("Pilihan Menu:\n");
gotoxy(_X - 6, _Y + 11);
printf("1. Kalkulator Standar\n");
gotoxy(_X - 6, _Y + 12);
printf("2. Kalkulator Akar Kuadrat\n");
gotoxy(_X - 6, _Y + 13);
printf("3. Help\n");
gotoxy(_X - 6, _Y + 14);
printf("4. History Penggunaan Kakuraato\n");
gotoxy(_X - 6, _Y + 15);
printf("5. Credit\n");
gotoxy(_X - 6, _Y + 16);
printf("\n");
gotoxy(_X - 6, _Y + 17);
printf(" 0. Exit\n");
gotoxy(_X - 8, _Y + 18);
printf("\n\n");
gotoxy(_X - 8, _Y + 19);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",201,205, 205, 205 ,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205, 205, 205,187);
gotoxy(_X - 8, _Y + 20);
printf("%c Menu Yang Dipilih : [ ] %c\n",186,186);
gotoxy(_X - 8, _Y + 21);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",200, 205, 205, 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205, 205, 205,188);
gotoxy(_X - 8, _Y + 22);
printf("\n\n");
gotoxy(_X - 8, _Y + 23);
printf("=====================================================================================\n");
}
void tampilKalkStandar(){
int _X = getScreenWidth() / 2 - 31;
int _Y = getScreenHeight() / 2 - 9;
system("cls");
gotoxy(_X - 2, _Y);
printf("========================================================================\n");
gotoxy(_X + 25, _Y + 2);
printf("KALKULATOR STANDAR\n");
gotoxy(_X + 2, _Y+5);
printf("\n\n");
gotoxy(_X +2, _Y + 6);
printf("Ekspresi");
gotoxy(_X +20, _Y + 6);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,187);
gotoxy(_X +2, _Y + 7);
printf("Matematika");
gotoxy(_X +20, _Y + 7);
printf("%c %c\n",186,186);
gotoxy(_X +2, _Y + 8);
printf("Yang Dihitung");
gotoxy(_X +20, _Y + 8);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,188);
gotoxy(_X +2, _Y + 9);
printf("\n");
gotoxy(_X +2, _Y + 10);
printf("Hasil");
gotoxy(_X +20, _Y + 10);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,187);
gotoxy(_X +2, _Y + 11);
printf("Perhitungan");
gotoxy(_X +20, _Y + 11);
printf("%c %c\n",186,186);
gotoxy(_X +2, _Y + 12);
printf("Ekspresi");
gotoxy(_X +20, _Y + 12);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,188);
gotoxy(_X +2, _Y + 13);
printf("\n\n");
gotoxy(_X +2, _Y + 15);
printf("Silakan tekan huruf Q untuk kembali ke home menu : \n");
gotoxy(_X +2, _Y + 16);
printf("Atau tekan huruf apapun selain Q untuk kembali menggunakan kalkualtor standar");
gotoxy(_X - 2, _Y + 18);
printf("========================================================================\n");
}
void tampilKalkAkur(){
int _X = getScreenWidth() / 2 - 31;
int _Y = getScreenHeight() / 2 - 9;
system("cls");
gotoxy(_X - 2, _Y - 4);
printf("========================================================================\n\n");
gotoxy(_X + 23, _Y - 2);
printf("KALKULATOR AKAR KUADRAT\n");
gotoxy(_X + 20, _Y - 1);
printf("(bentuk umum x^2 + x + 1 = 0)");
gotoxy(_X + 2, _Y+1);
printf("\n\n");
gotoxy(_X +2, _Y + 2);
printf("Ekspresi");
gotoxy(_X +20, _Y + 2);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,187);
gotoxy(_X +2, _Y + 3);
printf("Matematika");
gotoxy(_X +20, _Y + 3);
printf("%c %c\n",186,186);
gotoxy(_X +2, _Y + 4);
printf("Yang Dihitung");
gotoxy(_X +20, _Y + 4);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,188);
gotoxy(_X +2, _Y + 5);
printf("\n");
gotoxy(_X +2, _Y + 6);
printf("Nilai");
gotoxy(_X +20, _Y + 6);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,187);
gotoxy(_X +2, _Y + 7);
printf("Akar");
gotoxy(_X +20, _Y + 7);
printf("%c %c\n",186,186);
gotoxy(_X +2, _Y + 8);
printf("Ke-1");
gotoxy(_X +20, _Y + 8);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,188);
gotoxy(_X +2, _Y + 9);
printf("\n");
gotoxy(_X +2, _Y + 10);
printf("Nilai");
gotoxy(_X +20, _Y + 10);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",201,205,205, 205, 205, 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,187);
gotoxy(_X +2, _Y + 11);
printf("Akar");
gotoxy(_X +20, _Y + 11);
printf("%c %c\n",186,186);
gotoxy(_X +2, _Y + 12);
printf("ke-2");
gotoxy(_X +20, _Y + 12);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,188);
gotoxy(_X +2, _Y + 15);
printf("Silakan tekan huruf Q untuk kembali ke home menu : ");
gotoxy(_X +2, _Y + 16);
printf("Atau tekan huruf apapun selain Q untuk kembali menggunakan kalkualtor akar kuadrat");
gotoxy(_X - 2, _Y + 19);
printf("========================================================================\n");
}
void gotoxy(int x, int y) {
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void tampilCredit(){
int _X = getScreenWidth() / 2 - 31;
int _Y = getScreenHeight() / 2 - 9;
system("cls");
gotoxy(_X - 2, _Y);
printf("========================================================================\n");
gotoxy(_X + 30, _Y + 1);
printf("CREDIT\n");
gotoxy(_X - 2, _Y + 2);
printf("========================================================================\n");
gotoxy(_X + 30, _Y + 4);
printf("AUTHOR \n\n");
gotoxy(_X + 22, _Y + 5);
printf("Danu Mahesa (211524037)\n");
gotoxy(_X + 21, _Y + 6);
printf("Husna Maulana (211524045)\n");
gotoxy(_X + 17, _Y + 7);
printf("Rachmat Purwa Saputra (211524054)\n\n");
gotoxy(_X + 28, _Y + 9);
printf("Kelas : 1B \n");
gotoxy(_X + 23, _Y + 11);
printf("D4 Teknik Informatika\n");
gotoxy(_X + 31, _Y + 12);
printf("2022");
gotoxy(_X - 2, _Y + 14);
printf("========================================================================\n");
getche();
}
void tampilHelp(){
int _X = getScreenWidth() / 2 - 31;
int _Y = getScreenHeight() / 2 - 9;
FILE *help = NULL;
system("cls");
gotoxy(_X + 19, _Y - 7);
printf("======================\n");
gotoxy(_X + 28, _Y - 6);
printf("HELP \n");
gotoxy(_X + 19, _Y - 5);
printf("======================\n");
char isiHelp[300];
help = fopen("Help.txt", "r");
if(help == NULL){
printf("File Doesn't Exist");
getche();
}else {
int i = 1;
while(fscanf(help,"%[^\n]%*c", isiHelp) == 1){
gotoxy(_X - 15, _Y - 2 + i);
printf("%s\n",isiHelp);
i++;
}
getche();
}
fclose(help);
printf("\n");
printf("\n\nInput Number 0 For Back to Main Menu : ");
}
void printBanner() {
int i,j;
int widthOfScreen = getScreenWidth();
int heightOfScreen = getScreenHeight();
int _X = widthOfScreen / 2 - 31;
int _Y = heightOfScreen / 2 - 9;
char banner_active[6][68] = {"==] ==] =====] ==] ==]==] ==]======] =====] ========] ======] ",
"==| ==[/==[__==]==| ==[/==| ==|==[__==]==[__==]L__==[__/==[___==]",
"=====[/ =======|=====[/ ==| ==|======[/=======| ==| ==| ==|",
"==| ==] ==[__==|==[_==] ==| ==|==[__==]==[__==| ==| ==| ==|",
"==| ==]==| ==|==| ==]L======[/==| ==|==| ==| ==| L======[/",
"L_/ L_/L_/ L_/L_/ L_/ L_____/ L_/ L_/L_/ L_/ L_/ L_____/ "
};
for (i = 0; i < 6; i++) {
gotoxy(_X, _Y + 1 + i);
for (j = 0; j < 68; j++) {
printASCIIforBanner(banner_active[i][j]);
}
printf("\n");
}
}
void printASCIIforBanner(char ch) {
if (ch == '=') {
printf("%c", 219);
} else if (ch == '|') {
printf("%c", 186);
} else if (ch == ']') {
printf("%c", 187);
} else if (ch == '/') {
printf("%c", 188);
} else if (ch == '[') {
printf("%c", 201);
} else if (ch == 'L') {
printf("%c", 200);
} else if (ch == ' ') {
printf("%c", 32);
} else if (ch == '_') {
printf("%c", 205);
}
}
void printASCIIforHistTable(char ch) {
if (ch == '=') {
printf("%c", 196);
} else if (ch == '[') {
printf("%c", 218);
} else if (ch == 'L') {
printf("%c", 192);
} else if (ch == 'T') {
printf("%c", 194);
} else if (ch == 'X') {
printf("%c", 197);
} else if (ch == '7') {
printf("%c", 191);
} else if (ch == '/') {
printf("%c", 217);
} else if (ch == '^') {
printf("%c", 193);
} else if (ch == '}') {
printf("%c", 195);
} else if (ch == '{') {
printf("%c", 180);
} else if (ch == '|') {
printf("%c", 179);
} else if (ch == ' ') {
printf("%c", 32);
}
}