Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Parque.h"
- #include <vector>
- ParqueEstacionamento::ParqueEstacionamento(unsigned int lot, unsigned int nMaxCli) : lotacao(lot), numMaximoClientes(nMaxCli)
- {
- vagas = lot;
- vector<InfoCartao> v = clientes;
- }
- unsigned int ParqueEstacionamento::getNumLugares() const
- {
- return this->vagas;
- }
- unsigned int ParqueEstacionamento::getNumMaximoClientes() const
- {
- return this->numMaximoClientes;
- }
- int ParqueEstacionamento::posicaoCliente(const string & nome) const
- {
- unsigned int i;
- for (i = 0; i < clientes.size() ; i++)
- {
- if (clientes[i].nome == nome)
- return i;
- }
- return -1;
- }
- bool ParqueEstacionamento::adicionaCliente(const string & nome)
- {
- if (clientes.size() == numMaximoClientes)
- return false;
- else
- {
- InfoCartao x;
- x.nome = nome;
- x.presente = false;
- clientes.push_back(x);
- return true;
- }
- }
- bool ParqueEstacionamento::entrar(const string & nome)
- {
- unsigned int i;
- if (clientes.size() == numMaximoClientes)
- return false;
- for (i = 0; i < clientes.size() ; i++)
- {
- if (clientes[i].nome == nome)
- {
- if (clientes[i].presente == true)
- {
- return false;
- }
- if (clientes[i].presente == false)
- {
- clientes.erase(clientes.begin() + i);
- return true;
- }
- }
- else
- {
- return false;
- }
- }
- return true;
- }
- bool ParqueEstacionamento::retiraCliente(const string & nome)
- {
- unsigned int i;
- if (entrar(nome) == false)
- for (i = 0; i < clientes.size(); i++)
- {
- if(clientes[i].nome == nome)
- {
- clientes[i].presente= false;
- vagas++;
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement