#include<iostream>
#include<cmath>
#include "rectangle.h"
using namespace std;
Rectangle::Rectangle():Quadrilateral()
{
a = Point(1,3);
b = Point(5,3);
c = Point(5,5);
d = Point(1,5);
}
Rectangle::Rectangle(Point &p1, Point &p2, Point &p3, Point &p4):
Quadrilateral(p1,p2,p3,p4)
{
validate();
}
void Rectangle::SetAll(Point &p1, Point &p2, Point &p3, Point &p4)
{
Quadrilateral::SetAll(p1,p2,p3,p4);
validate();
}
double Rectangle::Perimeter()
{
double side1 = a.Distance(b);
double side2 = b.Distance(c);
double side3 = c.Distance(d);
double side4 = d.Distance(a);
return(side1 + side2 + side3 + side4);
}
double Rectangle::Area()
{
double side1 = a.Distance(b);
double side2 = b.Distance(c);
double side3 = c.Distance(d);
double side4 = d.Distance(a);
return(side1 * side2);
}
void Rectangle::Print()
{
cout << "I'm a Rectangle" << endl;
Quadrilateral::Print();
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGNtYXRoPgojaW5jbHVkZSAicmVjdGFuZ2xlLmgiCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpSZWN0YW5nbGU6OlJlY3RhbmdsZSgpOlF1YWRyaWxhdGVyYWwoKQp7CglhID0gUG9pbnQoMSwzKTsKCWIgPSBQb2ludCg1LDMpOwoJYyA9IFBvaW50KDUsNSk7CglkID0gUG9pbnQoMSw1KTsKfQoKUmVjdGFuZ2xlOjpSZWN0YW5nbGUoUG9pbnQgJnAxLCBQb2ludCAmcDIsIFBvaW50ICZwMywgUG9pbnQgJnA0KToKCQkJUXVhZHJpbGF0ZXJhbChwMSxwMixwMyxwNCkKewoJdmFsaWRhdGUoKTsKfQoKdm9pZCBSZWN0YW5nbGU6OlNldEFsbChQb2ludCAmcDEsIFBvaW50ICZwMiwgUG9pbnQgJnAzLCBQb2ludCAmcDQpCnsKCVF1YWRyaWxhdGVyYWw6OlNldEFsbChwMSxwMixwMyxwNCk7Cgl2YWxpZGF0ZSgpOwp9Cgpkb3VibGUgUmVjdG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