|
lab_inheritance
Insidious Inheritance
|
An abstract base class that represents a Shape which has an area, perimeter, color, and can contain Vector2s. More...
#include <shape.h>
Public Member Functions | |
| 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... | |
| ~Shape () | |
| int | area () const |
| Computes and returns the area of the Shape in pixels. More... | |
| int | perimeter () const |
| Computes and returns the perimeter of the Shape in pixels. More... | |
| bool | contains (const Vector2 &p) const |
| Checks to see if the Vector2 p is contained inside of the Shape. More... | |
| 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... | |
Public Member Functions inherited from Drawable | |
| ~Drawable () | |
Protected Attributes | |
| Vector2 | center_ |
Private Attributes | |
| cs225::HSLAPixel | color_ |
An abstract base class that represents a Shape which has an area, perimeter, color, and can contain Vector2s.
Shapes are also drawable, so they are expected to know how to draw themselves to a PNG.
| Shape::Shape | ( | ) |
Constructs a new Shape with a default color and center.
| Shape::Shape | ( | const Vector2 & | center, |
| const cs225::HSLAPixel & | color | ||
| ) |
|
inline |
| int Shape::area | ( | ) | const |
| Vector2 Shape::center | ( | ) | const |
| HSLAPixel Shape::color | ( | ) | const |
| bool Shape::contains | ( | const Vector2 & | p | ) | const |
|
virtual |
| int Shape::perimeter | ( | ) | const |
|
virtual |
|
protected |
|
private |