src/main.rs aktualisiert
This commit is contained in:
parent
320cc799c0
commit
6bdff369e0
62
src/main.rs
62
src/main.rs
|
@ -1,34 +1,40 @@
|
||||||
use std::io;
|
use std::io;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
fn main(){
|
fn main(){
|
||||||
let mut score:i16 = 0;
|
let toobig = 4;
|
||||||
|
let mut score: i32 = 0;
|
||||||
while score < 32 {
|
while score < 32 {
|
||||||
println!("Vor dir sind drei Türen, eine von ihnen tötet dich");
|
println!("Vor dir sind drei Türen, eine von ihnen tötet dich. Durch welche gehst du? Gib eine Zahl zwischen 1 und 3 ein");
|
||||||
println!("Durch welche gehst du? Gib eine Zahl zwischen 1 und 3 ein");
|
let secretnumber: i8 = rand::thread_rng().gen_range(1..=3);
|
||||||
let secretnumber = rand::thread_rng().gen_range(1..=3);
|
let guess = input();
|
||||||
let mut guess = String::new();
|
|
||||||
|
if guess < toobig{
|
||||||
io::stdin()
|
println!("Bitte befolge die Anweisungen");
|
||||||
.read_line(&mut guess)
|
|
||||||
.expect("Failed to read line");
|
|
||||||
if guess.chars().any(|c| c.is_digit(10)){
|
|
||||||
|
|
||||||
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 {
|
else if guess == secretnumber{
|
||||||
println!("die option ist unbekannt");
|
println!("Dein score: {}", score);
|
||||||
}
|
println!("Du bist tot");
|
||||||
else {
|
std::process::exit(0);
|
||||||
println!("Du hast überlebt");
|
}
|
||||||
score = score += 1;
|
else {
|
||||||
println!("Der Geist ist hinter der Tür {}", secretnumber);
|
println!("Du hast überlebt");
|
||||||
}}
|
let score = score += 1;
|
||||||
else {
|
println!("Der Geist war hinter der Tür {}", secretnumber);
|
||||||
println!("Die Option ist unbekannt")
|
}
|
||||||
}}
|
|
||||||
|
}
|
||||||
println!("Du hast gewonnen");
|
println!("Du hast gewonnen");
|
||||||
}
|
}
|
||||||
|
fn input()-> i8{
|
||||||
|
let mut guess = String::new();
|
||||||
|
io::stdin()
|
||||||
|
.read_line(&mut guess)
|
||||||
|
.expect("Failed to read line");
|
||||||
|
|
||||||
|
if guess.chars().any(|c| c.is_digit(10)){
|
||||||
|
if guess == "4"{
|
||||||
|
let guess: i8 = guess.trim().parse().expect("Please type a number!");
|
||||||
|
return guess
|
||||||
|
}}
|
||||||
|
return 4;
|
||||||
|
}
|
Loading…
Reference in a new issue