代写C代码 代做C程序 C辅导 C家教

远程写代码 Debug 讲解答疑 不是中介,本人直接写

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

 第一部分:写一个名为Rectangle 的类

 

lab 10 需要注意的是 从第二次lab开始,= ==<<这些运算符在这次的Assignment里也将会用到。你可以用lab 10 所提供的答案。

 

第二部分:写一个名为RectanglePyramid的类

 

用第一部分所提供的Rectangle的类写一个名为RectanglePyramid的类,用全局变量pageWidth pageHeight 来表示页面水平和竖直将被划分的大小,(用像素(pixels)衡量:一个好的页面大小:pageWidth =600 pageHeight=800)。 所有矩形的在页面中的位置(location)和大小(sizes)是整数型像素(integer numbers)。左下角的像素是在(0,pageHeight),其他角(指右下角等)的位置如下图所示。

 

RectanglePyramid 的类建造一个金字塔,如下图所示,他的private members(私有成员)(换句话说attributes:属性)  包括:pyramidHeight, numInPyramid, xPyramidLocation, yPyramidLocation, pyramidsCreated, pyramidsExisting,, rectangleLengthArray rectangleArray. 前六个个成员是整数(integers.私有成员rectangleLengthArray 是一个指针显示整数型数组。(The private member rectangleLengthArray is a pointer to an array of integers.)私有成员rectangleArray 是一个 矩形 的数组,(在数组中的每一个矩形代表堆在挂钉中的其中一个)。第一个成员:pyramidHeight 将会给出金字塔的高度,看下图。接下来的两个成员将会衡量金字塔最下方矩形左下角位置(xPyramidLocation, yPyramidLocation),下一个成员pyramidsExisting 代表现有金字塔的数量, pyramidsExisting的值必须和金字塔存在的数量相同,一旦矩形堆被建造,这个值将会增加,一旦矩形堆被破坏或摧毁,这个值将会减少。下一个成员pyramidsCreated 计算程序建造金字塔的数量,每当矩形堆被建造,这个值将会增加。下一个成员rectangleLengthArray,是一个指针指向整数数组(a pointer to an array of integers不太确定怎么翻译)。数组rectangleLengthArray location 0 中的整数代表金字塔底部矩形长度(x dimension in number of pixels),数组rectangleLengthArray location [ i ]的整数代表了在矩形堆中第i个矩形的长度。最后一个成员,rectangleArray,是指针面向包含每一个金字塔中的矩形的矩形的数组 is a pointer to an array of Rectangles containing each Rectangle in the pyramid.

 

第一个矩形在rectangleArray  中是在金字塔的底部,最后一个rectangleArray中的矩形是在金字塔的最上方。所有的矩形在金字塔中拥有同样的高度(height)和长度(length),储存在rectangleLengthArray[ ] 中。

 

 

写一个名为RectanglePyramid 你必须包括

1.  一个默认函数

2.  一个构造函数,它可以将矩形的数据用金字塔(pyramid),金字塔高(pyramid height),和金字塔参数的坐标位置(xy)(location (x,y) of the pyramid as parameters)来表示。

  §    A constructor that takes the number of Rectangles in the pyramid, pyramid height, and the location (x,y) of the pyramid as parameters (arguments of constructor should be in the same order as the arguments are mentioned)

§    A constructor that takes the number of Rectangles in the pyramid, pyramid height, the location (x,y) of the pyramid and an array of Rectangle lengths as parameter

3.一个复制构造函数

4.一个折构函数

5.操作符重载 = <<

6.只在SetRectangleArray and SetPyramidHeight , SetPyramidsExisting, and SetPyramidsCreated中有增变函数, SetRectangleArray的增变函数有下列格式:

 void SetRectangleArray(int numInPyramidValue, int pyramidHeightValue, int xPyramidLocationValue, int yPyramidLocationValue, int *pyramidLengthArray);

 

9.只有getPyramidsExisting  getPyramidsCreated有访问函数

10.一个用来展示的函数会将矩形金字塔存为bitmap,在Rectangle的类中会用到这个函数,这个展示的函数的蓝本如下:

void RectanglePyramidDisplay(BMP& myImageValue);

相关推荐