Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the Code in (Visual Studio) C++ (2 files their links are posted below) all

ID: 3827751 • Letter: G

Question

Given the Code in (Visual Studio) C++ (2 files their links are posted below) all you have to do is implement the functions as declared

Question) Implement the functions as declared in the header file “Rectangle.h” in a new file “Rectangle.cpp” and submit only this new file. The implementation should include all of the following here (links would be provided scroll down please) Read the question carefully a snapshot of the question is provided.

Main file link - https://www.dropbox.com/s/7exoapaozabsxq8/HW3Main.txt?dl=0

Rectangle file link - https://www.dropbox.com/s/1diu46k0cz8j1mh/RECTANGLE_H.txt?dl=0


Once you are done paste your code here with a screenshot of the output as the answer to this question. Must be in C++

Homework 3 Classes: Constructors, Accessors and Mutators In this homework, you will use a class to draw simple rectangles on the screen. You will use constructors to set the dimensions and print character for the rectangles Problem: In your first programming job, you are asked to construct a class that represents a rectangle. It will contain a width and height as well as a character to be used in drawing the rectangle. You are given a header file that contains the declarations for the rectangle class and a file that contains the main function you will need to test your implementation Requirements You are required to implement the functions as declared in the header file "Rectangle.h" in a new file "Rectangle.cpp" and submit only this new file. The implementation should include Rectangle() A default constructor for the rectangle class that sets the width and height of the rectangle to zero(0) and the print character to a blank space, Rectangle (int width. int height, char printCharacter) A constructor for the rectangle class that sets the width, height, and print character for the rectangle. The constructor should check the width and height and change negative values to zero (0) Rectangle() A destructor for the class, that doesn't do anything at this point, but is included for completeness. void Print 0 A method that prints the rectangle to the screen using the print character in the class.

Explanation / Answer

Here is the code for Rectangle.cpp:


// Homework #3 Header File
// **** DO NOT ALTER THIS FILE ****

#include <iostream>
#include "Rectangle.h"

using namespace std;

Rectangle::Rectangle()
{
    _width = _height = 0;
    _printCharacter = ' ';
}

Rectangle::Rectangle(int width, int height, char printCharacter)
{
    SetWidth(width);
    SetHeight(height);
    SetCharacter(printCharacter);
}

Rectangle::~Rectangle()
{
}

void Rectangle::Print()
{
   for(int i = 0; i < _height; i++)
   {
      for(int j = 0; j < _width; j++)
          cout << _printCharacter;
      cout << endl;  
   }
}

void Rectangle::SetWidth(int width)
{
   if(width >= 0)
       _width = width;
}

void Rectangle::SetHeight(int height)
{
   if(height >= 0)
       _height = height;
}
  
void Rectangle::SetCharacter(char printCharacter)
{
    _printCharacter = printCharacter;
}

int Rectangle::GetArea()
{
    return _width * _height;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote