src/main.rs aktualisiert
fixed issue 3
This commit is contained in:
parent
8518f96429
commit
f009c492c8
24
src/main.rs
24
src/main.rs
|
@ -1,27 +1,29 @@
|
||||||
use std::io;
|
use std::io;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
fn main(){
|
fn main(){
|
||||||
let mut score:u32 = 0;
|
let mut score:i16 = 0;
|
||||||
while score < 32 {
|
while score < 32 {
|
||||||
println!("Vor dir sind drei Türen");
|
println!("Vor dir sind drei Türen, eine von ihnen tötet dich");
|
||||||
println!("Eine von ihnen tötet dich ");
|
println!("Durch welche gehst du? Gib eine Zahl zwischen 1 und 3 ein");
|
||||||
println!("Durch welche gehst du?");
|
|
||||||
println!("Gib eine Zahl zwischen 1 und 3 ein");
|
|
||||||
let secretnumber = rand::thread_rng().gen_range(1..=3);
|
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);
|
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!");
|
let guess: u32 = guess.trim().parse().expect("Please type a number!");
|
||||||
if guess == secretnumber {
|
if guess == secretnumber {
|
||||||
println!("Dein score: {}", score);
|
println!("Dein score: {}", score);
|
||||||
println!("Du bist tot");
|
println!("Du bist tot");
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
if guess > 4 {
|
||||||
|
println!("die option ist unbekannt")
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
println!("Du hast überlebt");
|
println!("Du hast überlebt");
|
||||||
let _score = score += 1;
|
let _score = score += 1;
|
||||||
}
|
println!("Der Geist ist hinter der Tür {}", secretnumber);
|
||||||
}
|
}}
|
||||||
println!("Du hast gewonnen");
|
println!("Du hast gewonnen");
|
||||||
}
|
}
|
Loading…
Reference in a new issue