]> git.sur5r.net Git - c128-kasse/blobdiff - kasse.c
makefile, status array in config.h
[c128-kasse] / kasse.c
diff --git a/kasse.c b/kasse.c
index 546c387101f59a903ee5ab435a3e0a0c3a30110b..f2ba8a531b4353a20ebf4f681c9e366515413493 100644 (file)
--- a/kasse.c
+++ b/kasse.c
@@ -1,6 +1,8 @@
 #include <stdio.h>
 #include <conio.h>
+#include <stdlib.h>
 
+#include "config.h"
 #include "kasse.h"
 // conf
 // drucker 4 oder 5
@@ -15,9 +17,9 @@ void print_screen() {
        uc i = 0;
        clrscr();
        printf("C128-Kassenprogramm\n\n");
-       printf("Eingenommen: %.2d Euro, Verkauft: %d Flaschen\n\n", money * 100, items_sold);
-       for (; i < NUM_ITEMS; ++i)
-               printf("Item %x: %s (%d Cents, %d mal verkauft)\n", i, status[i].item_name, status[i].preis, status[i].times_sold);
+       printf("Eingenommen: 1337 Euro, Verkauft: 42 Flaschen\n\n");
+       for (; i < num_items; ++i)
+               printf("Item %x: %s (%d Cents, %d mal verkauft)\n", i, status[i].item_name, status[i].price, status[i].times_sold);
        printf("\nBefehle: s) Save Data\n");
 }
 
@@ -34,12 +36,14 @@ void buy(uc n) {
                printf("Wieviel Einheiten \"%s\"?\n", status[n].item_name);
                while (1) {
                        c = getchar();
+                       printf("das war %x\n", c);
                        if (c == 32)
                                break;
-                       else if (c > 47 && c < 58)
+                       else if (c > 47 && c < 60)
                                einheiten += (c - 48);
                }
                status[n].times_sold += einheiten;
+               money += status[n].price * einheiten;
                money += status[n].preis * einheiten;
                items_sold += einheiten;
        }
@@ -49,12 +53,12 @@ int main() {
        static uc c;
        /* TODO: remove */
        status[0].item_name = "cola";
-       status[0].preis = 230;
+       status[0].price = 230;
        status[0].times_sold = 0;
        status[1].item_name = "mate";
-       status[1].preis = 150;
+       status[1].price = 150;
        status[0].times_sold = 0;
-       for (c = 2; c < NUM_ITEMS; ++c)
+       for (c = 2; c < 15; ++c)
                status[c].item_name = NULL;
        while (1) {
                /* Bildschirm anzeigen */
@@ -62,7 +66,7 @@ int main() {
                /* Tastatureingaben abfragen */
                c = getchar();
                /* und eventuell weitere Dialoge anzeigen */
-               if (c > 47 && c < 58)
+               if (c > 47 && c < 60)
                        buy(c - 48);
                else if (c == 115)
                        save_data();