src/main.rs aktualisiert
Added code to detect if the input has an letter
This commit is contained in:
parent
0a8c1d9a98
commit
790507ced6
18
src/main.rs
18
src/main.rs
|
@ -11,8 +11,13 @@ fn main(){
|
||||||
io::stdin()
|
io::stdin()
|
||||||
.read_line(&mut guess)
|
.read_line(&mut guess)
|
||||||
.expect("Failed to read line");
|
.expect("Failed to read line");
|
||||||
if guess.trim().is_empty() {
|
|
||||||
println!("Die opiton ist unknown");
|
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 {
|
else {
|
||||||
|
|
||||||
|
@ -23,14 +28,13 @@ fn main(){
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
if guess > 4 {
|
if guess > 4 {
|
||||||
println!("die option ist unbekannt")
|
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!("Der Geist ist hinter der Tür {}", secretnumber);
|
||||||
}
|
}}}}
|
||||||
}
|
|
||||||
}
|
|
||||||
println!("Du hast gewonnen");
|
println!("Du hast gewonnen");
|
||||||
}
|
|
||||||
|
}
|
Loading…
Reference in a new issue