-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cs
255 lines (236 loc) · 9.25 KB
/
main.cs
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
class MainClass
{
private static NAluno naluno = new NAluno();
private static NMatricula nmatricula = new NMatricula();
private static NCurso ncurso = new NCurso();
public static void Main() {
Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-BR");
int op = 0;
Console.WriteLine ("----- Aplicativo de Escolar ------");
do {
try
{
op = Menu();
switch (op)
{
case 01: AlunoListar(); break;
case 02: AlunoInserir(); break;
case 03: AlunoAtualizar(); break;
case 04: AlunoExcluir(); break;
case 05: MatriculaListar(); break;
case 06: MatriculaInserir(); break;
case 07: MatriculaAtualizar(); break;
case 08: MatriculaExcluir(); break;
case 09: CursoListar(); break;
case 10: CursoInserir(); break;
case 11: CursoAtualizar(); break;
case 12: CursoExcluir(); break;
}
}
catch (Exception erro)
{
Console.WriteLine(erro.Message);
op = 100;
}
} while (op != 0);
Console.WriteLine("Bye.....");
}
public static int Menu()
{
Console.WriteLine();
Console.WriteLine("----------------------------------");
Console.WriteLine("01 - Aluno - Listar");
Console.WriteLine("02 - Aluno - Inserir");
Console.WriteLine("03 - Aluno - Atualizar");
Console.WriteLine("04 - Aluno - Excluir");
Console.WriteLine("05 - Matricula - Listar");
Console.WriteLine("06 - Matricula - Inserir");
Console.WriteLine("07 - Matricula - Atualizar");
Console.WriteLine("08 - Matricula - Excluir");
Console.WriteLine("09 - Curso - Listar");
Console.WriteLine("10 - Curso - Inserir");
Console.WriteLine("11 - Curso - Atualizar");
Console.WriteLine("12 - Curso - Excluir");
Console.WriteLine("0 - Fim");
Console.Write("Informe uma opção: ");
int op = int.Parse(Console.ReadLine());
Console.WriteLine();
return op;
}
public static void AlunoListar()
{
Console.WriteLine("----- Lista de Alunos -----");
Aluno[] cs = naluno.Listar();
if (cs.Length == 0)
{
Console.WriteLine("Nenhum aluno cadastrado");
return;
}
foreach (Aluno c in cs) Console.WriteLine(c);
Console.WriteLine();
}
public static void AlunoInserir()
{
Console.WriteLine("----- Inserção de Alunos -----");
Console.Write("Informe um código para aluno: ");
int id = int.Parse(Console.ReadLine());
Console.Write("Informe uma descrição para o aluno: ");
string descricao = Console.ReadLine();
Console.Write("Informe o nome: ");
string nome = Console.ReadLine();
Console.Write("Informe o endereço: ");
string endereco = Console.ReadLine();
Console.Write("Informe o telefone: ");
int telefone = int.Parse(Console.ReadLine());
// Instanciar a classe de aluno
Aluno c = new Aluno(id, descricao, nome, endereco, telefone);
// Inserção de aluno
naluno.Inserir(c);
}
public static void AlunoAtualizar()
{
Console.WriteLine("----- Atualização de Alunos -----");
AlunoListar();
Console.Write("Informe um código de aluno para alterar: ");
int id = int.Parse(Console.ReadLine());
Console.Write("Informe uma descrição de aluno: ");
string descricao = Console.ReadLine();
// Instanciar a classe de Aluno
Aluno c = new Aluno(id, descricao);
// Inserção de Aluno
naluno.Atualizar(c);
}
public static void AlunoExcluir()
{
Console.WriteLine("----- Exclusão de Alunos -----");
AlunoListar();
Console.Write("Informe um código de aluno para excluir: ");
int id = int.Parse(Console.ReadLine());
// Procurar o aluno com esse id
Aluno c = naluno.Listar(id);
// Exclui o aluno do cadastrado
naluno.Excluir(c);
}
public static void MatriculaListar()
{
Console.WriteLine("----- Lista de Matriculas -----");
Matricula[] ps = nmatricula.Listar();
if (ps.Length == 0)
{
Console.WriteLine("Nenhuma matricula cadastrada");
return;
}
foreach (Matricula p in ps) Console.WriteLine(p);
Console.WriteLine();
}
public static void MatriculaInserir()
{
Console.WriteLine("----- Inserção de matriculas -----");
Console.Write("Informe um código para a matricula: ");
int id = int.Parse(Console.ReadLine());
Console.Write("Informe uma descrição: ");
string descricao = Console.ReadLine();
AlunoListar();
Console.Write("Informe o código do aluno com a matricula: ");
int idaluno = int.Parse(Console.ReadLine());
// Seleciona a categoria a partir do id
Aluno c = naluno.Listar(idaluno);
// Instanciar a classe de Produto
Matricula p = new Matricula(id, descricao, c);
// Inserção da produto
nmatricula.Inserir(p);
}
public static void MatriculaAtualizar()
{
Console.WriteLine("----- Atualização de matriculas -----");
MatriculaListar();
Console.Write("Informe um código para a matricula: ");
int id = int.Parse(Console.ReadLine());
Console.Write("Informe uma descrição: ");
string descricao = Console.ReadLine();
AlunoListar();
Console.Write("Informe o código do aluno para a matricula: ");
int idaluno = int.Parse(Console.ReadLine());
// Seleciona o aluno a partir do id
Aluno c = naluno.Listar(idaluno);
// Instanciar a classe de Matricula
Matricula p = new Matricula(id, descricao, c);
// Atualização de matricula
nmatricula.Atualizar(p);
}
public static void MatriculaExcluir()
{
Console.WriteLine("----- Exclusão de Matriculas -----");
MatriculaListar();
Console.Write("Informe um código de matricula para excluir: ");
int id = int.Parse(Console.ReadLine());
// Procurar a matricula com esse id
Matricula p = nmatricula.Listar(id);
// Exclui a matricula do cadastrado
nmatricula.Excluir(p);
}
public static void CursoListar() {
Console.WriteLine("----- Lista de Cursos -----");
// Lista os cursos
List<Curso> cs = ncurso.Listar();
if (cs.Count == 0) {
Console.WriteLine("Nenhum curso cadastrado");
return;
}
foreach(Curso c in cs) Console.WriteLine(c);
Console.WriteLine();
}
public static void CursoInserir() {
Console.WriteLine("----- Inserção de Cursos -----");
Console.Write("Informe um código para curso: ");
int id = int.Parse(Console.ReadLine());
Console.Write("Informe uma descrição para o curso: ");
string descricao = Console.ReadLine();
Console.Write("Informe a duração do curso: ");
string duracao = Console.ReadLine();
Console.Write("Informe o turno: ");
string turno = Console.ReadLine();
Console.Write("Informe o valor da mensalidade: ");
double valormensalidade = double.Parse(Console.ReadLine());
Console.Write("Informe o valor da matricula: ");
double valormatricula = double.Parse(Console.ReadLine());
// Instanciar a classe de Curso
Curso c = new Curso { Id = id, Descricao = descricao, Duracao = duracao, Turno = turno, ValorMensalidade = valormensalidade, ValorMatricula = valormatricula };
// Inserção de Curso
ncurso.Inserir(c);
}
public static void CursoAtualizar() {
Console.WriteLine("----- Atualização de Cursos -----");
AlunoListar();
Console.Write("Informe o código do curso a ser atualizado: ");
int id = int.Parse(Console.ReadLine());
Console.Write("Informe uma descrição para o curso: ");
string descricao = Console.ReadLine();
Console.Write("Informe a duração do curso: ");
string duracao = Console.ReadLine();
Console.Write("Informe o turno: ");
string turno = Console.ReadLine();
Console.Write("Informe o valor da mensalidade: ");
double valormensalidade = double.Parse(Console.ReadLine());
Console.Write("Informe o valor da matricula: ");
double valormatricula = double.Parse(Console.ReadLine());
// Instanciar a classe de Curso
Curso c = new Curso { Id = id, Descricao = descricao, Duracao = duracao, Turno = turno, ValorMensalidade = valormensalidade, ValorMatricula = valormatricula };
// Inserção de Curso
ncurso.Inserir(c);
}
public static void CursoExcluir() {
Console.WriteLine("----- Exclusão de Cursos -----");
AlunoListar();
Console.Write("Informe o código do curso a ser excluído: ");
int id = int.Parse(Console.ReadLine());
// Procura o curso com esse id
Curso c = ncurso.Listar(id);
// Exclui o curso do cadastro
ncurso.Excluir(c);
}
}