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