-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeste.java
More file actions
68 lines (57 loc) · 2.51 KB
/
Copy pathTeste.java
File metadata and controls
68 lines (57 loc) · 2.51 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
package formageometrica;
import java.util.Scanner;
import java.util.ArrayList;
public class Teste {
public static void main(String[] args) {
Espaco2D espaco = new Espaco2D();
Scanner entrada = new Scanner(System.in);
while(true) {
int escolhaMenu;
int escolhaForma;
System.out.print("\nMENU\n1.Adicionar Forma\n2.Listar Formas\n0. SAIR\nDigite uma opcao: ");
escolhaMenu = entrada.nextInt();
switch(escolhaMenu) {
case 1:
ArrayList<Ponto2D> pontos = new ArrayList<>();
while(true) {
double x, y;
System.out.print("x = ");
x = entrada.nextDouble();
System.out.print("y = ");
y = entrada.nextDouble();
Ponto2D pontoDigitado = new Ponto2D(x, y);
pontos.add(pontoDigitado);
System.out.println("Você deseja digitar mais algum ponto?\n01. SIM\n02. NAO\nDigite uma opcao: ");
escolhaForma = entrada.nextInt();
if(escolhaForma == 2) {
break;
} else if (escolhaForma != 1) {
System.out.println("Escolha Inválida");
break;
}
}
Forma forma = Forma.geraForma(pontos);
if (forma == null) {
System.out.println("Seus pontos nao geraram nenhuma forma");
} else {
espaco.adicionarForma(forma);
System.out.println("Forma adicionada");
}
break;
case 2:
String lista = espaco.listarFormas();
System.out.println(lista);
break;
case 0:
System.out.println("Saindo...");
break;
default:
System.out.println("Opcao invalida");
break;
}
if(escolhaMenu == 0) {
break;
}
}
}
}