Classe Program:
Projeto projeto = new("Sistema de Inventário");
projeto.AdicionarTarefa("Criar tela de login");
projeto.AdicionarTarefa("Implementar banco de dados");
projeto.ExibirTarefas();
Classe Projeto:
namespace Encapsulamento;
internal class Projeto(string nome)
{
private List<string> tarefas = new();
public string Nome { get; set; } = nome;
public int QuantidadeTarefas => tarefas.Count;
public void AdicionarTarefa(string tarefa)
{
tarefas.Add(tarefa);
}
public void ExibirTarefas()
{
Console.WriteLine($"Projeto: {Nome}");
Console.WriteLine("Tarefas:");
foreach(string tarefa in tarefas) {
Console.WriteLine($"- {tarefa}");
}
Console.WriteLine($"Total: {QuantidadeTarefas} tarefas");
}
}