-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
157 lines (111 loc) · 6.82 KB
/
Main.java
File metadata and controls
157 lines (111 loc) · 6.82 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import java.io.IOException;
import java.util.*;
import static java.lang.System.exit;
public class Main {
public static final String VERMELHO = "\u001B[31m";
public static final String VERDE = "\u001B[32m";
public static final String AMARELO = "\u001B[33m";
public static final String AZUL = "\u001B[34m";
public static final String BRANCO = "\u001B[37m";
public static final String GameOver = "┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼\n" +
"███▀▀▀██┼███▀▀▀███┼███▀█▄█▀███┼██▀▀▀\n" +
"██┼┼┼┼██┼██┼┼┼┼┼██┼██┼┼┼█┼┼┼██┼██┼┼┼\n" +
"██┼┼┼▄▄▄┼██▄▄▄▄▄██┼██┼┼┼▀┼┼┼██┼██▀▀▀\n" +
"██┼┼┼┼██┼██┼┼┼┼┼██┼██┼┼┼┼┼┼┼██┼██┼┼┼\n" +
"███▄▄▄██┼██┼┼┼┼┼██┼██┼┼┼┼┼┼┼██┼██▄▄▄\n" +
"┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼\n" +
"███▀▀▀███┼▀███┼┼██▀┼██▀▀▀┼██▀▀▀▀██▄┼\n" +
"██┼┼┼┼┼██┼┼┼██┼┼██┼┼██┼┼┼┼██┼┼┼┼┼██┼\n" +
"██┼┼┼┼┼██┼┼┼██┼┼██┼┼██▀▀▀┼██▄▄▄▄▄▀▀┼\n" +
"███▄▄▄███┼┼┼─▀█▀┼┼─┼██▄▄▄┼██┼┼┼┼┼██▄\n" +
"┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼██┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼██┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼████▄┼┼┼▄▄▄▄▄▄▄┼┼┼▄████┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼┼▀▀█▄█████████▄█▀▀┼┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼┼┼┼█████████████┼┼┼┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼┼┼┼██▀▀▀███▀▀▀██┼┼┼┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼┼┼┼██┼┼┼███┼┼┼██┼┼┼┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼┼┼┼█████▀▄▀█████┼┼┼┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼┼┼┼┼███████████┼┼┼┼┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼▄▄▄██┼┼█▀█▀█┼┼██▄▄▄┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼▀▀██┼┼┼┼┼┼┼┼┼┼┼██▀▀┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼┼┼▀▀┼┼┼┼┼┼┼┼┼┼┼▀▀┼┼┼┼┼┼┼┼┼┼┼\n" +
"┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ \n"+
"GAME OVER";
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println(VERMELHO + "WELCOME" + VERDE + " TO" + AMARELO + " GEN" + AZUL + "IUS" + BRANCO);
System.out.println("\n Escolha uma opcao: \n");
System.out.println("1 - Jogar");
System.out.println("2 - Sair");
System.out.println(BRANCO);
Scanner sc = new Scanner(System.in);
int opcao = sc.nextInt();
if(opcao == 2) {
System.out.println("\n Obrigado por jogar!");
exit(0);
}
else {
// start game
int rodada = 0;
boolean cont = true;
ArrayList<String> dataNumbers = new ArrayList<String>();
do {
rodada++;
System.out.println("\n Rodada " + rodada);
int numeroAleatorio = generateNumber();
dataNumbers.add(Integer.toString(numeroAleatorio));
System.out.println("\nMemorize a sequencia de numeros: ");
dataNumbers.forEach(i ->{
System.out.print("\033[H\033[2J");
System.out.flush();
int randomNumber = Integer.parseInt(i);
System.out.printf(randomNumber == 1 ? VERMELHO + "|1|" : BRANCO + "|1|");
System.out.printf(" ");
System.out.printf(randomNumber == 2 ? VERDE + "|2|" : BRANCO + "|2|");
System.out.printf(" ");
System.out.printf(randomNumber == 3 ? AMARELO + "|3|" : BRANCO + "|3|");
System.out.printf(" ");
System.out.printf(randomNumber == 4 ? AZUL + "|4|" : BRANCO + "|4|");
System.out.printf("\n");
try {
Thread.sleep(700);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.print("\033[H\033[2J");
System.out.flush();
System.out.printf(BRANCO + "|1| |2| |3| |4|");
try {
Thread.sleep(300);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// cleans the screen
System.out.print("\033[H\033[2J");
System.out.flush();
});
System.out.println("\nDigite a sequencia: ");
String seq = sc.next();
String arrayToString = "";
for(String number: dataNumbers) {
arrayToString+=number;
}
if(!seq.equals(arrayToString)) {
cont =false;
System.out.println("\n" +GameOver);
System.out.println("\nA sequencia era: " + dataNumbers);
System.out.println("\nVoce chegou a " + rodada + "ª rodada!");
}
}
while (cont);
}
}
public static int generateNumber()
{
Random random = new Random();
int number = random.nextInt(4) + 1;
return number;
}
}