Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * client.h
- *
- */
- #ifndef CLIENT_H_
- #define CLIENT_H_
- #include <iostream>
- using namespace std;
- class Client {
- public:
- // constructors
- Client();
- Client(string, string, string, string, string);
- // getters
- string getName();
- string getAddr();
- string getTel();
- string getUserName();
- string getPassword();
- // setters
- void setName(string);
- void setAddr(string);
- void setTel(string);
- void setUserName(string);
- void setPassword(string);
- void Display();
- void output(ostream&);
- void input(istream&);
- void input();
- private:
- // fields
- string name;
- string addr;
- string tel;
- string userName;
- string password;
- };
- #endif /* CLIENT_H_ */
- /*
- *ad client.cpp
- *
- */
- #include <iostream>
- #include <iomanip>
- #include "client.h"
- using namespace std;
- Client::Client() {
- setName("");
- setAddr("");
- setTel("");
- setUserName("");
- setPassword("");
- }
- Client::Client(string new_name, string new_addr, string new_tel, string new_un, string new_pass) {
- setName(new_name);
- setAddr(new_addr);
- setTel(new_tel);
- setUserName(new_un);
- setPassword(new_pass);
- }
- string Client::getName() {
- return name;
- }
- string Client::getAddr() {
- return addr;
- }
- string Client::getTel() {
- return tel;
- }
- string Client::getUserName() {
- return userName;
- }
- string Client::getPassword() {
- return password;
- }
- void Client::setName(string p_name) {
- name = p_name;
- }
- void Client::setAddr(string p_addr) {
- addr = p_addr;
- }
- void Client::setTel(string p_tel) {
- tel = p_tel;
- }
- void Client::setUserName(string p_userName) {
- userName = p_userName;
- }
- void Client::setPassword(string p_password) {
- password = p_password;
- }
- void Client::input() {
- string tmp;
- cout << "INPUT CLIENT DATA" << endl;
- cout << "Name: ";
- cin >> tmp;
- setName(tmp);
- cout << "Address: ";
- cin >> tmp;
- setAddr(tmp);
- cout << "Telephone: ";
- cin >> tmp;
- setTel(tmp);
- cout << "Username: ";
- cin >> tmp;
- setUserName(tmp);
- cout << "Password: ";
- cin >> tmp;
- setPassword(tmp);
- }
- void Client::Display() {
- cout << setw(20) << left << name
- << setw(40) << left << addr
- << setw(15) << left << tel << endl;
- }
- /*
- * company.h
- *
- * Created on: 13 Ιαν 2017
- * Author: niksarid
- */
- #ifndef COMPANY_H_
- #define COMPANY_H_
- #include <vector>
- #include "client.h"
- #include "employee.h"
- #include "route.h"
- #include "ticket.h"
- #include "executedRoute.h"
- using namespace std;
- class Company {
- public:
- Company();
- ~Company();
- void add_client();
- void print_clients();
- void loadClientsFromFile();
- void saveClientsToFile();
- private:
- vector<Client> clients;
- };
- #endif /* COMPANY_H_ */
- void Company::loadClientsFromFile() {
- Client c;
- ifstream fin("clients.dat", ios::in | ios::binary);
- if (fin) {
- while( fin.read( reinterpret_cast<char*>( &c ), sizeof(c) ) )
- clients.push_back(c) ;
- fin.close();
- } else cout << "clients.dat not found!" << endl;
- }
- void Company::saveClientsToFile() {
- ofstream fout("clients.dat", ios::out | ios::binary);
- if (fout) {
- int size = clients.size();
- cout << size << " clients saved!n";
- for( const Client& c : clients )
- fout.write( reinterpret_cast<const char*>( &c ), sizeof(c) ) ;
- } else cout << "Error in saving the clients data file!n";
- }
- 2 [main] AirLine 7380 cygwin_exception::open_stackdumpfile: Dumping stack trace to AirLine.exe.stackdump
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement