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... | |
virtual int | area () const =0 |
Computes and returns the area of the Shape in pixels. More... | |
int | area () const |
virtual int | perimeter () const =0 |
Computes and returns the perimeter of the Shape in pixels. More... | |
int | perimeter () const |
virtual bool | contains (const Vector2 &p) const =0 |
Checks to see if the Vector2 p is contained inside of the Shape. More... | |
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... | |
Protected Attributes | |
Vector2 | center_ |
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 | ||
) |
|
pure virtual |
Vector2 Shape::center | ( | ) | const |
HSLAPixel Shape::color | ( | ) | const |
|
pure virtual |
|
virtual |
|
pure virtual |
|
virtual |