////File trapezoid.cpp

#include <iostream>
#include "math.h"
#include "trapezoid.h"

trapezoid::trapezoid()
{
	if(!registered)
	{
		figure::reg('Z',"trapezoid",&trapezoid::create);
		registered=true;
	}
}

bool trapezoid::registered=false;

static trapezoid dummy_trapezoid;

void trapezoid::compute_area()
{
	area=(top+base)*height/2;
}
void trapezoid::compute_perim()
{
	perimeter=top+base+sqrt(left_differ*left_differ+height*height)
		+sqrt(height*height+(base-left_differ-top)*(base-left_differ-top));
}
void trapezoid::display_fig()
{
	std::cout<<"Figure shape is trapezoid"<<std::endl;
	std::cout<<"The top length is : "<<top<<std::endl;
	std::cout<<"The base length is : "<<base<<std::endl;
	std::cout<<"The height is : "<<height<<std::endl;
	std::cout<<"The Left difference is : "<<left_differ<<std::endl;
	figure::display_fig();

}
void trapezoid::read_figure()
{
	std::cout<<"Enter the length of top >";
	std::cin>>top;
    std::cout<<"Enter the length of base >";
	std::cin>>base;
    std::cout<<"Enter the length of height >";
	std::cin>>height;
    std::cout<<"Enter the left difference >";
	std::cin>>left_differ;


}

figure* trapezoid::create()
{
	return new trapezoid;
}

 
