From f009c492c8439e71c5afc36311cbc71c8c9d30d0 Mon Sep 17 00:00:00 2001
From: robin <robin@noreply.localhost>
Date: Wed, 5 Jun 2024 22:26:31 +0200
Subject: [PATCH] src/main.rs aktualisiert

fixed issue 3
---
 src/main.rs | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 4659c1e..20fface 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,27 +1,29 @@
 use std::io;
 use rand::Rng;
 fn main(){
-    let mut score:u32 = 0;
+    let mut score:i16 = 0;
     while score < 32 {
-        println!("Vor dir sind drei Türen");
-        println!("Eine von ihnen tötet dich ");
-        println!("Durch welche gehst du?");
-        println!("Gib eine Zahl zwischen 1 und 3 ein");
+        println!("Vor dir sind drei Türen, eine von ihnen tötet dich");
+        println!("Durch welche gehst du? Gib eine Zahl zwischen 1 und 3 ein");
         let secretnumber = rand::thread_rng().gen_range(1..=3);
-        let mut guess = String::new(); 
-        let _input= io::stdin()
-                .read_line(&mut guess);
         println!("Der Geist ist hinter der Tür {}", secretnumber);
+        let mut guess = String::new(); 
+        io::stdin()
+            .read_line(&mut guess)
+            .expect("Failed to read line");
         let guess: u32 = guess.trim().parse().expect("Please type a number!"); 
         if guess == secretnumber {
             println!("Dein score: {}", score);
             println!("Du bist tot");
             std::process::exit(0);
         }
+        if guess > 4 {
+            println!("die option ist unbekannt")
+        }
         else  {
             println!("Du hast überlebt"); 
             let _score = score += 1;
-        }
-        }
+            println!("Der Geist ist hinter der Tür {}", secretnumber);
+        }}
         println!("Du hast gewonnen");
-}
\ No newline at end of file
+    }
\ No newline at end of file