]> git.sur5r.net Git - c128-kasse/blob - kasse.c
git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@12 af93e077-1a23-4f1e-9cbe...
[c128-kasse] / kasse.c
1 #include <stdio.h>
2 #include <conio.h>
3 #include <stdlib.h>
4
5 #include "config.h"
6 #include "kasse.h"
7 // conf
8 // drucker 4 oder 5
9 // pricee+getraenke
10 //
11 // graphic 4,0,10
12
13
14
15 /* Hauptbildschirm ausgeben */
16 void print_screen() {
17         uc i = 0;
18         clrscr();
19         printf("C128-Kassenprogramm\n\n");
20         printf("Eingenommen: %d Euro, Verkauft: %d Flaschen\n\n", money * 100, items_sold);
21         for (; i < num_items; ++i)
22                 printf("Item %x: %s (%d Cents, %d mal verkauft)\n", i, status[i].item_name, status[i].price, status[i].times_sold);
23         printf("\nBefehle: s) Save Data\n");
24 }
25
26 /* Wird ausgelagert */
27 void save_data() {
28 }
29
30 void buy(uc n) {
31         int negative = 1;
32         char entered[5] = {49, 0, 0, 0, 0};
33         uc i = 0;
34         uc c;
35         int einheiten;
36         if (status[n].item_name == NULL)
37                 printf("ERROR: No such item\n");
38         else {
39                 printf("Wieviel Einheiten \"%s\"?\n", status[n].item_name);
40                 while (1) {
41                         c = getchar();
42                         if (c == 13)
43                                 break;
44                         else if (c == 45 && i == 0)
45                                 negative = -1;
46                         else if (c > 47 && c < 58)
47                                 entered[i++] = c;
48                 }
49                 einheiten = atoi(entered) * negative;
50                 status[n].times_sold += einheiten;
51                 money += status[n].price * einheiten;
52                 items_sold += einheiten;
53         }
54 }
55
56 int main() {
57         static uc c;
58         while (1) {
59                 /* Bildschirm anzeigen */
60                 print_screen();
61                 /* Tastatureingaben abfragen */
62                 c = getchar();
63                 /* und eventuell weitere Dialoge anzeigen */
64                 if (c > 47 && c < 58)
65                         buy(c - 48);
66                 else if (c == 115)
67                         save_data();
68                 else if (c == 113)
69                         break;
70         }
71         printf("BYEBYE\n");
72 }