Vous êtes sur la page 1sur 5

République Algérienne Démocratique et Populaire

Ministère de l’enseignement supérieur et de la recherche


Scientifique

Université du 20 Aout 1955-skikda

Département :Génie électrique

Spécialité : Automatique et informatique industriel

Présente par : youcef islam feninekh group :01

Année Universitaire:2019/2020
1 RECTANGLE.H

#ifndef RECTANGLE_H
#define RECTANGLE_H
class Rectangle
{
private:
double height;
double width;
public
Rectangle();
Rectangle(double height, double width);
void setHeight (double);
void setWidth (double);
double getHeight() const
{
return height;
}
double getWidth() const
{
return width;
}
double getArea() const
{
double area ;
area= heiight * width ;
return area;
}
double getPerimetre () const
{
double (height * 2)+ (width * 2)
}
};
#endif

2 Rectangle.cpp
#include "Rectangle.h"
using namespace std;
Rectangle::Rectangle(){
height = 1 ;
width = 1 ;
};
Rectangle::Rectangle(double h, double w)
{
height=h ;
width = w;
}
void Rectangle::setHeight (double)
{
if (h>0)
height = h;
else
{
cout <<"invalid input for height\n";
exit(EXIT_FAILURE);
}
void Rectangle::setWidth (double w)
{
if (w>0)
width = w ;
else
{
cout <<"invalid input for width\n";
exit(EXIT_FAILURE);
}
}
}
3 main.cpp
# include "stdafx.h"
# include "iostream"
# include "Rectangle.h"

using namespace std ;


int _tmain(int argc, _TCHAR* argv[])
{
double height =0 ;
double width = 0 ;

do
{
cout <<"Please entre the height of the rectangle";
cin >> height ;
cout<<"please entre the width of the rectangle" ;
cin >> width ;
}
}

Vous aimerez peut-être aussi