设计并测试一个名为Rectangle的矩形类,其属性为矩形的左下角与右上角两个点的坐标,根据坐标能计算矩形的面积。
哈利波特英文版下载#include <iostream>
using namespace std;
class rectangle
{
public:
rectangle(float top,float bottom,float left,float right);
~rectangle( ) { }
float gettop( ) const { return itstop; }
float getbottom( ) const { return itsbottom; }
float getleft( ) const { return itsleft; }
float getright( ) const { return itsright; }
void ttop(float top) { itstop=top; }
void tbottom(float bottom) { itsbottom=bottom; }
void tleft(float left) { itsleft=left; }
void tright(float right) { itsright=right; }
float getarea( )const;
private:
float itstop;
float itsbottom;
float itsleft;
float itsright;
};
rectangle::rectangle(float top,float bottom,float left,float right)
{
itstop=top;
itsbottom=bottom;莫言 蛙
itsleft=left;
itsright=right;
}
两讫是什么意思float rectangle::getarea( ) const
janet{
float width=itsright-itsleft;ola>japane teacher 中文
记忆力不好怎么办
float height=itstop-itsbottom;
grave danger
return(width*height);
}
float main( )
{
float top,bottom,left,right;
cout<<"请输入参数top,bottom,left,right: "<<endl;
cin>>top;
cin>>bottom;
cin>>left;
cin>>right;
dialogue
rectangle myrectangle(top,bottom,left,right);
float area( );
cout<<"左下角的坐标是:("<<left<<","<<bottom<<")"<<endl;
cout<<"右上角角的坐标是:("<<right<<","<<top<<")"<<endl;
cout<<"area:"<<area<<"\n";
return 0;
let me go什么意思}