lab_inheritance
Insidious Inheritance
 All Classes Namespaces Files Functions Variables
Circle Class Reference

A subclass of Shape that represents a Circle in 2D space. More...

#include <circle.h>

Inheritance diagram for Circle:
[legend]
Collaboration diagram for Circle:
[legend]

Public Member Functions

 Circle (const Vector2 &center, const cs225::HSLAPixel &color, int radius)
 Constructs a new Circle with the given center, color, and radius. More...
 
int area () const
 Computes and returns the area of the Circle in pixels. More...
 
int perimeter () const
 Computes and returns the perimeter of the Circle in pixels. More...
 
bool contains (const Vector2 &p) const
 Checks to see if the given point is inside the Circle. More...
 
void draw (cs225::PNG *canvas) const
 Draws the Circle to the canvas. More...
 
int radius () const
 Gets the radius of the Circle in pixels. More...
 
void set_radius (int radius)
 Sets the radius of the Circle in pixels. More...
 
- Public Member Functions inherited from Shape
 Shape ()
 Constructs a new Shape with a default color and center. More...
 
 Shape (const Vector2 &center, 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 &center)
 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 ()
 

Private Member Functions

void drawPoints (cs225::PNG *canvas, int x, int y) const
 

Private Attributes

int radius_
 

Additional Inherited Members

- Protected Attributes inherited from Shape
Vector2 center_
 

Detailed Description

A subclass of Shape that represents a Circle in 2D space.

Constructor & Destructor Documentation

Circle::Circle ( const Vector2 center,
const cs225::HSLAPixel color,
int  radius 
)

Constructs a new Circle with the given center, color, and radius.

Parameters
centerpoint of the new Circle
colorof the new Circle
radiusof the new Circle in pixels

Member Function Documentation

int Circle::area ( ) const

Computes and returns the area of the Circle in pixels.

Returns
the area of the Circle in pixels
bool Circle::contains ( const Vector2 p) const

Checks to see if the given point is inside the Circle.

Parameters
p
Returns
true if p is inside the Circle
void Circle::draw ( cs225::PNG canvas) const
virtual

Draws the Circle to the canvas.

Parameters
canvas

Implements Drawable.

void Circle::drawPoints ( cs225::PNG canvas,
int  x,
int  y 
) const
private
int Circle::perimeter ( ) const

Computes and returns the perimeter of the Circle in pixels.

Returns
the perimeter of the Circle in pixels
int Circle::radius ( ) const

Gets the radius of the Circle in pixels.

Returns
the radius of the Circle in pixels
void Circle::set_radius ( int  radius)

Sets the radius of the Circle in pixels.

Parameters
radiusthe new radius of the Circle in pixels

Member Data Documentation

int Circle::radius_
private

The documentation for this class was generated from the following files: