internal class Curso
{
public string Nome { get; set; }
public int VagasTotais { get; set; }
private List<Estudante> matriculas;
public int VagasDisponiveis
{
get
{
return matriculas.Count - VagasTotais;
}
}
public Curso(string nome, int vagasTotais)
{
Nome = nome;
VagasTotais = vagasTotais;
matriculas = new List<Estudante>();
}
public bool Matricular(Estudante estudante)
{
if (VagasTotais == matriculas.Count)
{
Console.WriteLine("Erro: Não há vagas disponíveis para este curso.");
return false;
}
else
{
matriculas.Add(estudante);
Console.WriteLine($"O estudante {estudante.Nome}, foi matriculado com sucesso.");
return true;
}
}
public void ListarMatriculados()
{
Console.WriteLine("Estudantes matriculados em Lógica de Programação:");
foreach (var estudante in matriculas)
{
Console.WriteLine($"- {estudante}");
}
Console.WriteLine($"Vagas disponíveis: {VagasDisponiveis}");
}
}
internal class Estudante
{
public string Nome { get; set; }
public Estudante(string nome)
{
Nome = nome;
}
}