Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include "Parque.h"
  2. #include <vector>
  3.  
  4. ParqueEstacionamento::ParqueEstacionamento(unsigned int lot, unsigned int nMaxCli) : lotacao(lot), numMaximoClientes(nMaxCli)
  5. {
  6. vagas = lot;
  7. vector<InfoCartao> v = clientes;
  8. }
  9.  
  10. unsigned int ParqueEstacionamento::getNumLugares() const
  11. {
  12. return this->vagas;
  13. }
  14.  
  15. unsigned int ParqueEstacionamento::getNumMaximoClientes() const
  16. {
  17. return this->numMaximoClientes;
  18. }
  19.  
  20. int ParqueEstacionamento::posicaoCliente(const string & nome) const
  21. {
  22. unsigned int i;
  23. for (i = 0; i < clientes.size() ; i++)
  24. {
  25. if (clientes[i].nome == nome)
  26. return i;
  27. }
  28. return -1;
  29. }
  30.  
  31. bool ParqueEstacionamento::adicionaCliente(const string & nome)
  32. {
  33. if (clientes.size() == numMaximoClientes)
  34. return false;
  35. else
  36. {
  37. InfoCartao x;
  38. x.nome = nome;
  39. x.presente = false;
  40. clientes.push_back(x);
  41. return true;
  42. }
  43. }
  44.  
  45. bool ParqueEstacionamento::entrar(const string & nome)
  46. {
  47. unsigned int i;
  48. if (clientes.size() == numMaximoClientes)
  49. return false;
  50. for (i = 0; i < clientes.size() ; i++)
  51. {
  52. if (clientes[i].nome == nome)
  53. {
  54. if (clientes[i].presente == true)
  55. {
  56. return false;
  57. }
  58. if (clientes[i].presente == false)
  59. {
  60. clientes.erase(clientes.begin() + i);
  61. return true;
  62. }
  63. }
  64. else
  65. {
  66. return false;
  67. }
  68. }
  69. return true;
  70. }
  71.  
  72. bool ParqueEstacionamento::retiraCliente(const string & nome)
  73. {
  74. unsigned int i;
  75. if (entrar(nome) == false)
  76. for (i = 0; i < clientes.size(); i++)
  77. {
  78. if(clientes[i].nome == nome)
  79. {
  80. clientes[i].presente= false;
  81. vagas++;
  82. return true;
  83. }
  84. }
  85. return false;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement