src/main.rs aktualisiert
Fix the issue #6 partly it still accepts letters and symbols
This commit is contained in:
parent
6bdff369e0
commit
fe150166a4
12
src/main.rs
12
src/main.rs
|
@ -8,7 +8,7 @@ fn main(){
|
|||
let secretnumber: i8 = rand::thread_rng().gen_range(1..=3);
|
||||
let guess = input();
|
||||
|
||||
if guess < toobig{
|
||||
if guess > toobig{
|
||||
println!("Bitte befolge die Anweisungen");
|
||||
}
|
||||
else if guess == secretnumber{
|
||||
|
@ -21,7 +21,6 @@ fn main(){
|
|||
let score = score += 1;
|
||||
println!("Der Geist war hinter der Tür {}", secretnumber);
|
||||
}
|
||||
|
||||
}
|
||||
println!("Du hast gewonnen");
|
||||
}
|
||||
|
@ -31,10 +30,9 @@ fn input()-> i8{
|
|||
.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
|
||||
}}
|
||||
if guess.chars().any(|c| c.is_digit(10)){
|
||||
let guess: i8 = guess.trim().parse().expect("Please type a number!");
|
||||
return guess
|
||||
}
|
||||
return 4;
|
||||
}
|
Loading…
Reference in a new issue