Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include "Vende++.h"
- #include "Menus.h"
- #include "utils.h"
- // More
- #include "Cliente.h"
- #include "Produto.h"
- #include "Transacao.h"
- #include "Data.h"
- #include "defs.h"
- using namespace std;
- vector<Cliente> readclientetxt();
- // files reading
- vector<Cliente> clientes = readclientetxt();
- vector<Cliente> readclientetxt() //save the file clientes.txt in one vector of clientes (int ; string ; double)
- {
- vector<Cliente> clienteslista;//vector that is returned in the end (which is going to have Clients.txt info)
- ifstream fichClientes;//ifstream to store the text file, and then extract the information from it
- fichClientes.open("clientes.txt");//store the text file in the ifstream
- if (!fichClientes)//error message in case of non-existence of the file
- cerr << "ERROR 404 - Clients file not found";
- while (!fichClientes.eof())//cicle to create the vector (ends in end of file)
- {
- Cliente clienteauxdata(fichClientes);//create the cliente which is going to store the info of one line
- string clienteinfo; //string to store the line
- int numCliRead; // number of clients to read
- string numClientesR;
- getline(fichClientes, numClientesR); // Define conditions if a user don't digit a number
- numCliRead = stoi(numClientesR, nullptr, 10);
- while (numCliRead)
- {
- getline(fichClientes, clienteinfo);//store the line in clientinfo, next time its called, reads the next line
- string idRead;//string which stores id information
- string nameRead;//string which stores name information
- string amountRead; //string which stores amount information
- int stringcounter = 0; //store string character place
- for (int i = 0; clienteinfo[i] != char(32); i++)//cicle to read id , lê até encontrar o primeiro espaço char(20) é o espaço!
- {
- idRead = idRead + clienteinfo[i];
- stringcounter = i;
- }
- for (int k = stringcounter + 3; clienteinfo[k] != ';'; k++)//cicle to read name
- {
- nameRead = nameRead + clienteinfo[k];
- stringcounter = k;
- }
- nameRead = nameRead.substr(1, nameRead.size() - 2);
- for (int j = stringcounter + 2; clienteinfo[j]; j++)//cicle to read amount
- {
- amountRead = amountRead + clienteinfo[j];
- }
- clienteauxdata.setId(idRead);//convert string to int
- clienteauxdata.setNome(nameRead);
- clienteauxdata.setVolCompras(amountRead);//convert string to double
- //create the client
- clienteslista.push_back(clienteauxdata);//store client in vector next line
- }
- }
- return clienteslista;//return the vector
- }
- int main(){
- string loja, fichClients, fichProdutos, fichTransacoes;
- // pede a informacoo sobre o nome da loja e os 3 ficheiros com
- // informacoo de clientes, produtos e transacoes
- if(! infoInicial(loja, fichClients, fichProdutos, fichTransacoes))
- return(-1);
- // cria uma loja
- VendeMaisMais supermercado(loja, fichClients, fichProdutos, fichTransacoes);
- cout << "Informacao da loja '" << loja << " do supermercado Vende++:" << endl;
- cout << supermercado << endl; // mostra estatisticas da loja
- opcoesIniciais(supermercado); // menu inicial com as grandes opcoes
- // que implementam as funcioanlidades
- // disonibilizadas
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement