[Solved] CCC Rectangle

$25

File Name: CCC_Rectangle.zip
File Size: 122.46 KB

SKU: [Solved] CCC Rectangle Category: Tag:
5/5 - (1 vote)

Below is some code for a rectangle class that needs to be completed. Add member function declarations to the classdeclaration and member function definitions below the declaration. For the accessor functions, you can add the definitionsdirectly into the class declaration The goal is to code the class so that it works wthout changing the main program.You can cut and paste the code into a file (rectangle.cpp) in the Mimir IDE or any other environment where you can build andtest the code more easily.

#includeusing namespace std;// rectangle has a vertical height and horizontal width// The class below is a rectangle. It has two private// data members: height and width.// TODO: Complete the class declaration and definition.class rectangle {public:// TODO: declare a default constructor// sets height and width to the unit rectangle which is a square 11 size.// TODO: declare member function add// add the given addHeight to height and addWidth to width// @param int addHeight, int addWidth// @returns void// TODO: delcare member function void set// set the height to new_height and width to new_width// @param int new_height, int new_width// @returns void// TODO: declare member function draw// uses height as the vertical dimension (outer loop) and width as the horizontal// dimension (inner loop) to draw the rectangle with # characters.// TODO: define accessor for width// TODO: define accessor for height// TODO: declare a function that tells if a// rectangle is a squareprivate:int height;int width;};// TODO: implement a default constructor// sets height and width to the unit rectangle which is// a square 11 size.// TODO: Implement add member function// @param int addHeight, int addWidth// to addHeight to height and add addWidth to widthvoid rectangle::add(int addHeight, int addWidth){}// TODO: implement member function void set that assigns// new_height to height and new_width to width// @param int new_height, int new_widthvoid rectangle::set(int new_height, int new_width){}// TODO: declare member function void draw that uses// uses the height in an outer loop and the width in an// inner loop to draw the rectangle with # characters.void rectangle::draw(){}// TODO: Dont forget to define getWidth and getHeightint main(){// Declare 2 rectanglesrectangle r1, r2;// Draw the unit rectanglecout << unit rectangle << endl;r1.draw();// Set, print dimensions and drawr1.set(4, 3);cout << r1 is << r1.getHeight() << x << r1.getWidth() << endl;r1.draw();// Assign, increment, print dimensions and drawr2 = r1;r2.add(3, 4);cout << r2 is << r2.getHeight() << x << r2.getWidth() << endl;r2.draw();if (r2.isSquare())cout << r2 is a square << endl;elsecout << r2 is not a square << endl;return 0;}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CCC Rectangle
$25