-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
119 lines (112 loc) · 4.49 KB
/
index.html
File metadata and controls
119 lines (112 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Teste de Gastos Compulsivos</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f4f4f9;
}
#quiz-container {
max-width: 400px;
padding: 20px;
background-color: #fff;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
border-radius: 8px;
}
.button-group {
display: flex;
justify-content: space-around;
margin-top: 20px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border: none;
border-radius: 4px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #ddd;
}
</style>
</head>
<body>
<div id="quiz-container">
<h2>Bem-vindo ao Quiz de Gastos Compulsivos!</h2>
<p id="genero-texto">Escolha seu gênero para começar:</p>
<div class="button-group" id="genero-botoes">
<button onclick="iniciarQuiz('homem')">Homem</button>
<button onclick="iniciarQuiz('mulher')">Mulher</button>
</div>
<p id="saldo-texto" style="display: none;">Saldo: R$<span id="saldo">1000</span></p>
<p id="pergunta-texto" style="display: none;"></p>
<div class="button-group" id="resposta-botoes" style="display: none;">
<button onclick="gastar()">Sim</button>
<button onclick="proximaPergunta()">Não</button>
</div>
</div>
<script>
let saldo = 1000;
let genero = null;
let perguntaAtual = 0;
const perguntasHomem = [
{ texto: "Promoção de eletrônicos! Comprar um fone por R$250?", gasto: 250 },
{ texto: "Jaqueta de marca com 50% de desconto por R$300. Comprar?", gasto: 300 },
{ texto: "Convite para jogo de futebol com ingressos a R$200. Aceitar?", gasto: 200 },
{ texto: "Jantar com os amigos por R$150. Participar?", gasto: 150 },
{ texto: "Coleção de filmes clássicos por R$180. Comprar?", gasto: 180 }
];
const perguntasMulher = [
{ texto: "Promoção em conjunto de maquiagem por R$180. Comprar?", gasto: 180 },
{ texto: "Vestido de festa por R$350. Comprar?", gasto: 350 },
{ texto: "Dia de spa com amigas por R$400. Participar?", gasto: 400 },
{ texto: "Curso de culinária por R$150. Participar?", gasto: 150 },
{ texto: "Kit de produtos para cabelo por R$100. Comprar?", gasto: 100 }
];
let perguntas;
function iniciarQuiz(selecaoGenero) {
genero = selecaoGenero;
perguntas = genero === 'homem' ? perguntasHomem : perguntasMulher;
document.getElementById("genero-texto").style.display = 'none';
document.getElementById("genero-botoes").style.display = 'none';
document.getElementById("saldo-texto").style.display = 'block';
document.getElementById("pergunta-texto").style.display = 'block';
document.getElementById("resposta-botoes").style.display = 'flex';
exibirPergunta();
}
function exibirPergunta() {
if (perguntaAtual < perguntas.length) {
document.getElementById("pergunta-texto").textContent = perguntas[perguntaAtual].texto;
document.getElementById("saldo").textContent = saldo;
} else {
finalizarQuiz();
}
}
function gastar() {
saldo -= perguntas[perguntaAtual].gasto;
perguntaAtual++;
exibirPergunta();
}
function proximaPergunta() {
perguntaAtual++;
exibirPergunta();
}
function finalizarQuiz() {
document.getElementById("pergunta-texto").style.display = 'none';
document.getElementById("resposta-botoes").style.display = 'none';
let mensagem = saldo > 500 ? "Você aparenta ter um bom controle financeiro." : "Aparentemente você costuma gastar mais do que recebe.";
alert(mensagem);
window.location.reload();
}
</script>
</body>
</html>