rectangle.cpp

来自「设计并测试一个名为Rectangle的矩形类」· C++ 代码 · 共 81 行

CPP
81
字号
// Rectangle.cpp: implementation of the CRectangle class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Rectangle.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CRectangle::CRectangle(int top,int left,int bottom,int right)
{
	itsTop=top;
	itsLeft=left;
	itsBottom=bottom;
	itsRight=right;

}

CRectangle::~CRectangle()
{

}

int CRectangle::GetTop() const
{
	return itsTop;

}

int CRectangle::GetLeft() const
{
	return itsLeft;

}

int CRectangle::GetBottom() const
{
	return itsBottom;

}

int CRectangle::GetRight() const
{
	return itsRight;

}

void CRectangle::SetTop(int top)
{
	itsTop=top;

}

void CRectangle::SetLeft(int left)
{
	itsLeft=left;

}

void CRectangle::SetBottom(int bottom)
{
	itsBottom=bottom;

}

void CRectangle::SetRight(int right)
{
	itsRight=right;

}

int CRectangle::GetArea() const
{
	int Width=itsRight-itsLeft;
	int Height=itsTop-itsBottom;
	return(Width * Height);

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?