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