forked from jim/Jogo-da-adivinhacao
Compare commits
4 Commits
87d6028414
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ab7def81d | |||
| 439bd0caf2 | |||
| a55499bf40 | |||
| 30995e55d3 |
+47
@@ -0,0 +1,47 @@
|
||||
# Binários compilados
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Binário de teste, criado por 'go test -c'
|
||||
*.test
|
||||
|
||||
# Output de profiling do go tool cover
|
||||
*.out
|
||||
|
||||
# Dependências (se usar vendor)
|
||||
/vendor/
|
||||
|
||||
# Arquivo de workspace do Go (a menos que queira versionar)
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
# Variáveis de ambiente / segredos
|
||||
.env
|
||||
.env.local
|
||||
*.env
|
||||
|
||||
# Build outputs comuns (ajuste conforme seu projeto)
|
||||
/bin/
|
||||
/build/
|
||||
/dist/
|
||||
|
||||
# Arquivos de IDE / editor
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# Arquivos específicos do sistema operacional
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
||||
# Arquivos de configuração local
|
||||
config.local.yaml
|
||||
config.local.json
|
||||
@@ -9,14 +9,17 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
numero, tentativas := 7, 3
|
||||
const TENTATIVAS = 3
|
||||
numero := 7
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
|
||||
fmt.Println("Bem-vindo ao jogo de adivinhação!")
|
||||
fmt.Printf("Você tem %d tentativas para adivinhar o número entre 1 e 10.\n", tentativas)
|
||||
fmt.Printf("Você tem %d tentativas para adivinhar o número entre 1 e 10.\n", TENTATIVAS)
|
||||
|
||||
for i := 0; i <= tentativas; i++ {
|
||||
if i == tentativas {
|
||||
tentativa := 0
|
||||
|
||||
for tentativa < TENTATIVAS {
|
||||
if tentativa == TENTATIVAS {
|
||||
fmt.Println("Suas tentativas acabaram. O número correto era:", numero)
|
||||
break
|
||||
}
|
||||
@@ -29,24 +32,16 @@ func main() {
|
||||
fmt.Println("Deve ser informado um número.")
|
||||
continue
|
||||
}
|
||||
// talvez não necessite checar se o número é menor que um
|
||||
if chuteInt < 1 {
|
||||
fmt.Println("O número deve ser maior que 0.")
|
||||
continue
|
||||
}
|
||||
|
||||
if chuteInt < numero {
|
||||
fmt.Println("O número é maior")
|
||||
}
|
||||
|
||||
if chuteInt > numero {
|
||||
fmt.Println("O número é menor")
|
||||
}
|
||||
|
||||
if chuteInt == numero {
|
||||
switch {
|
||||
case chuteInt < numero:
|
||||
fmt.Println("O número é maior, tente novamente.")
|
||||
case chuteInt > numero:
|
||||
fmt.Println("O número é menor, tente novamente.")
|
||||
default:
|
||||
fmt.Println("Parabéns! Você acertou o número!")
|
||||
break
|
||||
}
|
||||
|
||||
tentativa++
|
||||
}
|
||||
}
|
||||
}
|
||||
// Comentário para testar alteração por outro usuário
|
||||
Reference in New Issue
Block a user