Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Last active April 12, 2021 19:05
Show Gist options
  • Save luisdeol/89405e7283de9c421b9d4d8b9f94cc4d to your computer and use it in GitHub Desktop.
Save luisdeol/89405e7283de9c421b9d4d8b9f94cc4d to your computer and use it in GitHub Desktop.
Artigo Estrutura de Dados - Parte #1 - Fila para Gerenciamento de Senhas de Atendimento
using System;
using System.Collections.Generic;
namespace DataStructuresCsharp
{
public class GerenciadorFilaAtendimento
{
private Queue<int> _filaAtendimento;
private int _proximoNumeroParaGerar = 1;
public GerenciadorFilaAtendimento()
{
_filaAtendimento = new Queue<int>();
}
public int GerarSenha()
{
_filaAtendimento.Enqueue(_proximoNumeroParaGerar);
Console.WriteLine("Senha gerada.");
return _proximoNumeroParaGerar++;
}
public void ChamarProximo()
{
var proximoNumeroDaFila = _filaAtendimento.Dequeue();
Console.WriteLine($"Próxima senha: {proximoNumeroDaFila}");
}
public void MostrarFila()
{
Console.Write("Senhas da Fila: ");
foreach (var senha in _filaAtendimento)
{
Console.Write(senha + " ");
}
Console.WriteLine();
}
public void ReiniciarFila()
{
_filaAtendimento.Clear();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment