-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCampeonato.java
122 lines (112 loc) · 2.84 KB
/
Campeonato.java
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
import java.util.Scanner;
public class Campeonato{
private static Scanner aux = new Scanner(System.in);
private static Jogador[] jogadores=new Jogador[5];
public static boolean checaNome(String nome){
String nome1;
for(int i=0;i<5;i++){
if(jogadores[i]!=null){
nome1=jogadores[i].getNome();
if(nome1.equals(nome)){
return true;
}
}
}
return false;
}
public static void incluirJogador(){
System.out.println("\nInsira o nome do jogador: ");
String nome=aux.next();
if(checaNome(nome)==true){
System.out.println("Nome já inserido.");
return;
}
for(int i=0;i<5;i++){
if(jogadores[i]==null){
jogadores[i]=new Jogador();
jogadores[i].setNome(nome);
System.out.println("Inserido com sucesso");
return;
}
if(i==4&&jogadores[i]!=null){
System.out.println("Número de jogadores excedido.");
return;
}
}
}
public static void removerJogador(){
System.out.println("\nLista de jogadores:");
for(int i=0;i<5;i++){
if(jogadores[i]!=null){
System.out.println(jogadores[i].getNome());
}
}
System.out.println("\nQual dos jogadores deseja retirar?");
String nome=aux.next();
if(checaNome(nome)==false){
System.out.println("Não há jogador com esse nome.");
}
else{
for(int i=0;i<5;i++){
if(jogadores[i]!=null&&jogadores[i].getNome()==nome){
jogadores[i]=null;
}
}
}
}
public static void iniciar(){
for(int x=0;x<13;x++){
for(int i=0;i<5;i++){
if(jogadores[i]!=null){
System.out.println("Rolando dados para "+jogadores[i].getNome());
jogadores[i].rolarDados();
System.out.print("\nDados obtidos: ");
jogadores[i].mostrarDados();
}
}
}
}
public static void mostrar(){
}
public static void gravar(){
}
public static void ler(){
}
public static void main(String[] args){
int opcao;
do{
System.out.println("\nJogo General");
System.out.println("1-Incluir jogador.");
System.out.println("2-Remover jogador.");
System.out.println("3-Iniciar/Reiniciar o campeonato.");
System.out.println("4-Mostrar cartela de resultados.");
System.out.println("5-Gravar dados.");
System.out.println("6-Ler dados.");
System.out.println("0-Sair.\n");
opcao=aux.nextInt();
if(opcao==1){
incluirJogador();
}
else if(opcao==2){
removerJogador();
}
else if(opcao==3){
iniciar();
}
else if(opcao==4){
mostrar();
}
else if(opcao==5){
gravar();
}
else if(opcao==6){
ler();
}
else if(opcao==0){
}
else{
System.out.println("Opção inválida");
}
}while(opcao!=0);
}
}