File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change 44 "Number-Guessing/internal/helper"
55 "fmt"
66 "strconv"
7+ "time"
78)
89
910func main () {
@@ -31,6 +32,7 @@ func main() {
3132 randomNumber := helper .RandomNumberGenerator ()
3233 attempts := 0
3334 chances := helper .GetChancesForLevel (selectedLevel )
35+ startTime := time .Now ()
3436 for {
3537 fmt .Println ()
3638 fmt .Printf ("Enter your guess: " )
@@ -54,6 +56,7 @@ func main() {
5456 }
5557 if guessedNumber == randomNumber {
5658 fmt .Printf ("Congratulations! You guessed the correct number in %d attempts\n " , attempts )
59+ fmt .Printf ("You took %v time\n " , time .Since (startTime ).Truncate (time .Second ))
5760 break
5861 }
5962 if chances > 0 {
@@ -65,6 +68,7 @@ func main() {
6568 continue
6669 } else {
6770 fmt .Println ("Game Over! You have used all the attempts" )
71+ fmt .Printf ("You took %v time\n " , time .Since (startTime ).Truncate (time .Second ))
6872 }
6973 break
7074 }
You can’t perform that action at this time.
0 commit comments