lab_inheritance
Insidious Inheritance
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...
 
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 &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...
 

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::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

◆ area()

int Circle::area ( ) const
virtual

Computes and returns the area of the Circle in pixels.

Returns
the area of the Circle in pixels

Implements Shape.

◆ contains()

bool Circle::contains ( const Vector2 p) const
virtual

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

Parameters
p
Returns
true if p is inside the Circle

Implements Shape.

◆ draw()

void Circle::draw ( cs225::PNG *  canvas) const
virtual

Draws the Circle to the canvas.

Parameters
canvas

Implements Drawable.

◆ perimeter()

int Circle::perimeter ( ) const
virtual

Computes and returns the perimeter of the Circle in pixels.

Returns
the perimeter of the Circle in pixels

Implements Shape.

◆ radius()

int Circle::radius ( ) const

Gets the radius of the Circle in pixels.

Returns
the radius of the Circle in pixels

◆ set_radius()

void Circle::set_radius ( int  radius)

Sets the radius of the Circle in pixels.

Parameters
radiusthe new radius of the Circle in pixels

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