src/main.rs aktualisiert
Added code so only numbers are exepted
This commit is contained in:
parent
790507ced6
commit
fa8fc571f3
18
src/main.rs
18
src/main.rs
|
@ -11,15 +11,7 @@ fn main(){
|
|||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
|
||||
if guess.chars().any(|c| c.is_alphabetic()) {
|
||||
println!("Deine Eingabe enthält einen Buchstaben");
|
||||
}
|
||||
else {
|
||||
if guess.trim().is_empty() {
|
||||
println!("Die opiton ist unbekannt");
|
||||
}
|
||||
else {
|
||||
if guess.chars().any(|c| c.is_digit(10)){
|
||||
|
||||
let guess: u32 = guess.trim().parse().expect("Please type a number!");
|
||||
if guess == secretnumber {
|
||||
|
@ -34,7 +26,9 @@ fn main(){
|
|||
println!("Du hast überlebt");
|
||||
let _score = score += 1;
|
||||
println!("Der Geist ist hinter der Tür {}", secretnumber);
|
||||
}}}}
|
||||
}}
|
||||
else {
|
||||
println!("Die Option ist unbekannt")
|
||||
}}
|
||||
println!("Du hast gewonnen");
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue