From 6b9011afcb5740a2e9edd834f877e5bd62ad9c83 Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Mon, 29 Jan 2024 16:09:03 +0100 Subject: [PATCH] Ungueltige Wetteinsaetze werden abgefangen --- src/main/c/Stefan/slot_machine.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/c/Stefan/slot_machine.c b/src/main/c/Stefan/slot_machine.c index dfddd13..4d1e33f 100644 --- a/src/main/c/Stefan/slot_machine.c +++ b/src/main/c/Stefan/slot_machine.c @@ -34,11 +34,17 @@ int userInput(){ } int getBet(int balance){ - int bet; - printf("Wetteinsatz: "); - bet = userInput(); - return bet; + while(1){ + printf("Wetteinsatz: "); + int bet = userInput(); + + if(bet <= balance && bet >= 0){ + return bet; + } else { + printf("Ungueltige Eingabe!\n"); + } + } } void welcomeMessage(){