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