lab_inheritance
Insidious Inheritance
|
A subclass of Shape that represents a rectangle in 2D space. More...
#include <rectangle.h>
Public Member Functions | |
Rectangle (const Vector2 ¢er, const cs225::HSLAPixel &color, int width, int height) | |
Constructs a new Rectangle with the given center, color, height, and width. More... | |
int | area () const |
Computes and returns the area of the Rectangle in pixels. More... | |
int | perimeter () const |
Computes and returns the perimeter of the Rectangle in pixels. More... | |
bool | contains (const Vector2 &p) const |
Checks to see if the given Vector2 p is inside of the Rectangle. More... | |
void | draw (cs225::PNG *canvas) const |
Draws the Rectangle onto the canvas. More... | |
int | width () const |
Gets the width of the Rectangle in pixels. More... | |
void | set_width (int width) |
Sets the width of the Rectangle in pixels. More... | |
int | height () const |
Gets the height of the Rectangle in pixels. More... | |
void | set_height (int height) |
Sets the height of the Rectangle in pixels. More... | |
Public Member Functions inherited from Shape | |
Shape () | |
Constructs a new Shape with a default color and center. More... | |
Shape (const Vector2 ¢er, const cs225::HSLAPixel &color) | |
Constructs a new Shape with the given center and color. More... | |
int | area () const |
int | perimeter () const |
bool | contains (const Vector2 &p) const |
Vector2 | center () const |
Gets the center Vector2 of the Shape. More... | |
virtual void | set_center (const Vector2 ¢er) |
Sets the center Vector2 of the Shape. More... | |
cs225::HSLAPixel | color () const |
Gets the color of the Shape. More... | |
void | draw (cs225::PNG *canvas) const |
This method will draw the object onto the canvas. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Shape | |
Vector2 | center_ |
A subclass of Shape that represents a rectangle in 2D space.
Rectangle::Rectangle | ( | const Vector2 & | center, |
const cs225::HSLAPixel & | color, | ||
int | width, | ||
int | height | ||
) |
|
virtual |
|
virtual |
|
virtual |
int Rectangle::height | ( | ) | const |
|
virtual |
void Rectangle::set_height | ( | int | height | ) |
void Rectangle::set_width | ( | int | width | ) |
int Rectangle::width | ( | ) | const |