From: Michael Stapelberg Date: Sun, 1 Nov 2009 20:12:55 +0000 (+0100) Subject: handle selling more than 9 items (whole input will be interpreted, not only first... X-Git-Tag: rgb2rv7~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c09f1f6662bab5ac8370b2ee99e51a50d4d34ff1;p=c128-kasse handle selling more than 9 items (whole input will be interpreted, not only first digit) --- diff --git a/src/itemz.c b/src/itemz.c index aec8f4c..408c3b4 100644 --- a/src/itemz.c +++ b/src/itemz.c @@ -28,7 +28,7 @@ static void itemz_print_screen() { cprintf("Error: Could not format price %d\r\n", status.status[i].price); exit(1); } - cprintf("Eintrag %x: %s (%s, %d mal verkauft)\r\n", + cprintf("Eintrag %2d: %s (%s, %d mal verkauft)\r\n", i, status.status[i].item_name, buffer, status.status[i].times_sold); } cprintf("\r\nn) Neu d) Loeschen s) Speichern m) Credit Modus q) Beenden\r\n"); diff --git a/src/kasse.c b/src/kasse.c index b347397..1f14cde 100644 --- a/src/kasse.c +++ b/src/kasse.c @@ -41,7 +41,7 @@ static void print_screen() { Eingenommen: %s, Verkauft: %ld Flaschen, Drucken: %s\r\n\r\n", time, profit, items_sold, (printing == 1 ? "ein" : "aus")); for (; i < status.num_items; ++i) - cprintf("Eintrag %x: %s (%d Cents, %d mal verkauft)\r\n", + cprintf("Eintrag %2d: %s (%d Cents, %d mal verkauft)\r\n", i, status.status[i].item_name, status.status[i].price, status.status[i].times_sold); cprintf("\r\nBefehle: s) Daten sichern d) Drucken umschalten\r\ g) Guthabenverwaltung z) Zeit setzen\r\ @@ -254,7 +254,9 @@ int main() { c = get_input(); /* ...display dialogs eventually */ if (*c > 47 && *c < 58) { - buy_stock((*c) - 48); + /* if the input starts with a digit, we will interpret it as a number + * for the item to be sold */ + buy_stock(atoi(c)); toggle_videomode(); clrscr(); toggle_videomode();