Академический Документы
Профессиональный Документы
Культура Документы
#ifndef COLOCVIU2018TAXI_COMPANIE_H
#define COLOCVIU2018TAXI_COMPANIE_H
#include <array>
#include <iostream>
class Companie {
protected:
string denumire;
int codFiscal;
double tarif;
int profit;
public:
Companie(string den, int cod, double tar);
Companie(){};
virtual double calcTarif(){};
virtual void write(ostream& out) = 0;
bool operator<(const Companie& other){
return profit < other.profit;
}
friend ostream& operator<<(ostream& out, Companie& c);
};
#endif //COLOCVIU2018TAXI_COMPANIE_H
//
// Created by Alex on 5/27/2019.
//
#ifndef COLOCVIU2018TAXI_COMPANIEPRECOMANDA_H
#define COLOCVIU2018TAXI_COMPANIEPRECOMANDA_H
#include <vector>
#include "../Companie.h"
class Precomanda {
private:
string nume, data, ora, sursa, destinatie;
double km;
bool aeroport;
public:
Precomanda(string n, string d, string o, string s, string dest, double k, bool
a)
: nume(n), data(d), ora(o), sursa(s), destinatie(dest), km(k),
aeroport(a) {};
void afisPrecomanda(ostream& os){
os << "Numele clientului: " << nume << '\n';
os << "Data si ora precomenzii: " << data << " " << ora << '\n';
os << "Locul de preluare: " << sursa << '\n';
os << "Destinatia: " << destinatie << '\n';
}
int getKm(){
return km;
}
bool toAirport(){
return aeroport;
}
};
#endif //COLOCVIU2018TAXI_COMPANIEPRECOMANDA_H
//
// Created by Alex on 5/27/2019.
//
#ifndef COLOCVIU2018TAXI_COMPANIECONTROLSIDRIVER_H
#define COLOCVIU2018TAXI_COMPANIECONTROLSIDRIVER_H
#include <vector>
#include "Companie.h"
class CostControl {
string sursa;
string destinatie;
double km;
public:
CostControl(string s, string d, double k) : sursa(s), destinatie(d), km(k) {};
double getCost(int tarif){
return km * tarif;
}
void afisCostControl(ostream& out) {
out << "Sursa: " << sursa << '\n';
out << "Destinatie: " << destinatie << '\n';
out << "Numar km: " << km << '\n';
}
};
class DesignatedDriver {
string sofer1, sofer2, cod1, cod2;
public:
DesignatedDriver(const string &sofer1, const string &sofer2, const string
&cod1, const string &cod2) : sofer1(
sofer1), sofer2(sofer2), cod1(cod1), cod2(cod2) {};
void afisDesignatedDriver(ostream& out) {
out << "Sofer1: " << sofer1 << '\n';
out << "Sofer2: " << sofer2 << '\n';
out << "Cod1: " << cod1 << '\n';
out << "Cod2: " << cod2 << '\n';
}
};
out << "Compania are un numar de " << designatedDriverCount << " comenzi cu
Designated Driver. \n";
for (int i = 0; i < designatedDriver.size(); i++) {
out << "Comanda cu numarul " << i + 1 << '\n';
designatedDriver[i].afisDesignatedDriver(out);
}
}
};
int CompanieControlSiDriver::costControlCount = 0;
int CompanieControlSiDriver::designatedDriverCount = 0;
#endif //COLOCVIU2018TAXI_COMPANIECONTROLSIDRIVER_H
//
// Created by Alex on 5/27/2019.
//
#ifndef COLOCVIU2018TAXI_COMPANIERENTLEASING_H
#define COLOCVIU2018TAXI_COMPANIERENTLEASING_H
#include <vector>
#include <cstdlib>
#include "Companie.h"
class RentACar{
string nume, data1, ora1, locPreluare, data2, ora2, locPredare;
int tarif;
public:
RentACar(const string &nume, const string &data1, const string &ora1, const
string &locPreluare,
const string &data2, const string &ora2, const string &locPredare,
double tarif) : nume(nume),
data1(data1),
ora1(ora1), locPreluare(
locPreluare), data2(data2), ora2(ora2), locPredare(locPredare)
{
srand(NULL);
tarif = (rand() % 10) + 10;
}
};
};
#endif //COLOCVIU2018TAXI_COMPANIERENTLEASING_H
#include <iostream>
#include <algorithm>
#include "cmake-build-debug/CompaniePreComanda.h"
#include "CompanieControlSiDriver.h"
int main() {
CompaniePreComanda comp("Taxi Alex", 29432, 3.23);
comp.solicitaPrecomanda(Precomanda("alex", "27.05.2019", "23:30", "Slatina",
"buc", 180, false));
comp.solicitaPrecomanda(Precomanda("marius", "29.05.2019", "18:42", "Rahova",
"Centru", 5, false));
//cout << comp;
vector < Companie* > c;
c.push_back(&comp);
c.push_back(&driver);
//cout << *c[1];
sort(c.begin(), c.end());
cout << *c[0];
return 0;
}
//
// Created by Alex on 5/27/2019.
//
#ifndef COLOCVIU2018TAXI_COMPANIE_H
#define COLOCVIU2018TAXI_COMPANIE_H
#include <array>
#include <iostream>
class Companie {
protected:
string denumire;
int codFiscal;
double tarif;
int profit;
public:
Companie(string den, int cod, double tar);
Companie(){};
virtual double calcTarif(){};
virtual void write(ostream& out) = 0;
bool operator<(const Companie& other){
return profit < other.profit;
}
friend ostream& operator<<(ostream& out, Companie& c);
};
#endif //COLOCVIU2018TAXI_COMPANIE_H
//
// Created by Alex on 5/27/2019.
//
#ifndef COLOCVIU2018TAXI_COMPANIEPRECOMANDA_H
#define COLOCVIU2018TAXI_COMPANIEPRECOMANDA_H
#include <vector>
#include "../Companie.h"
class Precomanda {
private:
string nume, data, ora, sursa, destinatie;
double km;
bool aeroport;
public:
Precomanda(string n, string d, string o, string s, string dest, double k, bool
a)
: nume(n), data(d), ora(o), sursa(s), destinatie(dest), km(k),
aeroport(a) {};
void afisPrecomanda(ostream& os){
os << "Numele clientului: " << nume << '\n';
os << "Data si ora precomenzii: " << data << " " << ora << '\n';
os << "Locul de preluare: " << sursa << '\n';
os << "Destinatia: " << destinatie << '\n';
}
int getKm(){
return km;
}
bool toAirport(){
return aeroport;
}
};
#endif //COLOCVIU2018TAXI_COMPANIEPRECOMANDA_H
//
// Created by Alex on 5/27/2019.
//
#ifndef COLOCVIU2018TAXI_COMPANIECONTROLSIDRIVER_H
#define COLOCVIU2018TAXI_COMPANIECONTROLSIDRIVER_H
#include <vector>
#include "Companie.h"
class CostControl {
string sursa;
string destinatie;
double km;
public:
CostControl(string s, string d, double k) : sursa(s), destinatie(d), km(k) {};
double getCost(int tarif){
return km * tarif;
}
void afisCostControl(ostream& out) {
out << "Sursa: " << sursa << '\n';
out << "Destinatie: " << destinatie << '\n';
out << "Numar km: " << km << '\n';
}
};
class DesignatedDriver {
string sofer1, sofer2, cod1, cod2;
public:
DesignatedDriver(const string &sofer1, const string &sofer2, const string
&cod1, const string &cod2) : sofer1(
sofer1), sofer2(sofer2), cod1(cod1), cod2(cod2) {};
void afisDesignatedDriver(ostream& out) {
out << "Sofer1: " << sofer1 << '\n';
out << "Sofer2: " << sofer2 << '\n';
out << "Cod1: " << cod1 << '\n';
out << "Cod2: " << cod2 << '\n';
}
};
out << "Compania are un numar de " << designatedDriverCount << " comenzi cu
Designated Driver. \n";
for (int i = 0; i < designatedDriver.size(); i++) {
out << "Comanda cu numarul " << i + 1 << '\n';
designatedDriver[i].afisDesignatedDriver(out);
}
}
};
int CompanieControlSiDriver::costControlCount = 0;
int CompanieControlSiDriver::designatedDriverCount = 0;
#endif //COLOCVIU2018TAXI_COMPANIECONTROLSIDRIVER_H
//
// Created by Alex on 5/27/2019.
//
#ifndef COLOCVIU2018TAXI_COMPANIERENTLEASING_H
#define COLOCVIU2018TAXI_COMPANIERENTLEASING_H
#include <vector>
#include <cstdlib>
#include "Companie.h"
class RentACar{
string nume, data1, ora1, locPreluare, data2, ora2, locPredare;
int tarif;
public:
RentACar(const string &nume, const string &data1, const string &ora1, const
string &locPreluare,
const string &data2, const string &ora2, const string &locPredare,
double tarif) : nume(nume),
data1(data1),
ora1(ora1), locPreluare(
locPreluare), data2(data2), ora2(ora2), locPredare(locPredare)
{
srand(NULL);
tarif = (rand() % 10) + 10;
}
};
};
#endif //COLOCVIU2018TAXI_COMPANIERENTLEASING_H