Esempio n. 1
0
void Circle::setRadius(double rad) {
    // radius should not be negative
    radius = (rad < 0) ? 0 : rad;
    // now recalculate area and perimeter
    calculateArea();
    calculatePerimeter();
}
Esempio n. 2
0
//constructor
Rectangle::Rectangle(int x,int y)
{
    height=y;
    width=x;
    calculateArea();
    calculatePerimeter();
}
Esempio n. 3
0
void Rect::setDimensions(double l, double h) {
    // we do not want to accept negative values
    // for length and width
    length = (l < 0) ? 0 : l;
    height = (h < 0) ? 0 : h;
    // now update area and perimeter
    calculateArea();
    calculatePerimeter();
}