1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#pragma once
#include <iostream>
using namespace std;
#include <cmath>
#include <string>
class Flacon
{
private:
string nom;
double volume;
double pH;
public:
Flacon(void);
Flacon(string un_nom, double un_volume, double un_Ph);
ostream& etiquette(ostream& sortie) const;
void set_Nom(string un_nom);
void set_volume(double un_volume);
void set_pH(double un_pH);
string get_Nom()const;
double get_volume()const;
double get_pH()const;
~Flacon(void);
};
Dans le Flacon.cpp
#include <iostream>
#include "Flacon.h"
using namespace std;
#include <cmath>
#include <string>
Flacon::Flacon(void)
{
}
Flacon::Flacon(string un_nom, double un_volume, double un_Ph):nom(un_nom),volume(un_volume),pH( un_Ph)
{
}
Flacon::~Flacon(void)
{
}
void Flacon::set_Nom(string un_nom)
{
nom=un_nom;
}
void Flacon:: set_volume(double un_volume)
{
volume=un_volume;
}
void Flacon::set_pH(double un_pH)
{
pH=un_pH;
}
string Flacon::get_Nom()const
{
return nom;
}
double Flacon::get_volume()const
{
return volume;
}
double Flacon::get_pH()const
{
return pH;
}
ostream& Flacon::etiquette(ostream& sortie) const
{
sortie<<nom<<" : "<<volume<<" ml, "<<"pH";
sortie<<pH;
return sortie;
}
ostream& operator<<(ostream& sortie, Flacon const& Flacon)
{
return Flacon.etiquette(sortie);
}
Flacon operator +(Flacon F1,const Flacon& F2)
{
F1.set_pH(log10((pow(10.0, -F1.get_pH())*F1.get_volume()+pow(10.0,-F2.get_pH())*F2.get_volume())/(F1.get_volume()+F2.get_volume())));
F1.set_Nom(F1.get_Nom()+F2.get_Nom());
F1.set_volume(F1.get_volume()+F2.get_volume());
return F1;
}
void afficher_melange(Flacon const& f1, Flacon const& f2)
{
cout<<" Si je melange "<<endl;
cout<<" \t\""<<f1<<"\""<<endl;
cout<<"avec"<<endl;
cout<<" \t\""<<f2<<"\""<<endl;
cout<<"J'obtiens : "<<endl;
cout<<" \t\""<<(f1 + f2)<<"\""<<endl;
}
/*Flacon& operator +=(const Flacon& F)
{
double set_Nom(get_Nom()+F.get_Nom());
double set_volume(get_volume()+F.get_volume());
double set_Ph(log10(2*pow(10.0,-get_Ph())*get_Volume()/(get_Volume()+get_Volume())));
return *this;
}* cette partie du code ne marche pas et il y a des erreurs/ |
Partager