]> git.sur5r.net Git - c128-kasse/blob - kasse.c
git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@8 af93e077-1a23-4f1e-9cbe-9382a...
[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 // preise+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: 1337 Euro, Verkauft: 42 Flaschen\n\n");
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         static uc einheiten = 1;
32         static uc c;
33         if (status[n].item_name == NULL)
34                 printf("ERROR: No such item\n");
35         else {
36                 printf("Wieviel Einheiten \"%s\"?\n", status[n].item_name);
37                 while (1) {
38                         c = getchar();
39                         printf("das war %x\n", c);
40                         if (c == 32)
41                                 break;
42                         else if (c > 47 && c < 60)
43                                 einheiten += (c - 48);
44                 }
45                 status[n].times_sold += einheiten;
46                 money += status[n].price * einheiten;
47                 items_sold += einheiten;
48         }
49 }
50
51 int main() {
52         static uc c;
53         /* TODO: remove */
54         status[0].item_name = "cola";
55         status[0].price = 230;
56         status[0].times_sold = 0;
57         status[1].item_name = "mate";
58         status[1].price = 150;
59         status[0].times_sold = 0;
60         for (c = 2; c < 15; ++c)
61                 status[c].item_name = NULL;
62         while (1) {
63                 /* Bildschirm anzeigen */
64                 print_screen();
65                 /* Tastatureingaben abfragen */
66                 c = getchar();
67                 /* und eventuell weitere Dialoge anzeigen */
68                 if (c > 47 && c < 60)
69                         buy(c - 48);
70                 else if (c == 115)
71                         save_data();
72                 else if (c == 113)
73                         break;
74         }
75         printf("BYEBYE\n");
76 }