Last active
April 12, 2021 19:05
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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