Advertisement
Guest User

Complexe.cpp

a guest
Nov 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include "Complexe.h"
  2.  
  3. Complexe::Complexe(float i, float r): _imaginaire(i), _reel(r) {}
  4.  
  5. // Complexe::Complexe() : imaginaire(0), reel(0){};
  6.  
  7. void Complexe::editer() const {
  8.     cout << "Imaginaire :" << _imaginaire << endl;
  9.     cout << "Reel :" << _reel << endl;
  10. }
  11.  
  12. bool Complexe::operator>(Complexe complx) const{
  13.     float carrePartieReel1 = _reel * _reel;
  14.     float carrePartieReel2 = complx._reel * complx._reel;
  15.     float carrePartieImaginaire1 = _imaginaire * _imaginaire;
  16.     float carrePartieImaginaire2 = complx._imaginaire * complx._imaginaire;
  17.  
  18.     float sommeFirst = carrePartieImaginaire1 + carrePartieReel1;
  19.     float sommeSecond = carrePartieImaginaire2 + carrePartieReel2;
  20.  
  21.     return ( sommeFirst > sommeSecond ? true : false );
  22. }
  23.  
  24. void Complexe::set_Reel(float r) {
  25.     _reel = r;
  26. }
  27. void Complexe::set_Imaginaire(float i){
  28.     _imaginaire = i;
  29. }
  30. float Complexe::get_Reel() const {
  31.     return _reel;
  32. }
  33. float Complexe::get_Imaginaire() const{
  34.     return _imaginaire;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement