Fishtank
Public Member Functions | List of all members
Shape Class Reference

Represents an ASCII-art drawing and its corresponding bounding box. More...

#include <shape.h>

Public Member Functions

 Shape (std::vector< std::string > shape)
 Take in an array of lines and right-pad the shorter ones with ' ' to the width of the longest line. More...
 
int width () const
 
int height () const
 
char charAt (int col, int row) const
 Fetch the character at the given coordinate pair. More...
 

Detailed Description

Represents an ASCII-art drawing and its corresponding bounding box.

Definition at line 7 of file shape.h.

Constructor & Destructor Documentation

◆ Shape()

Shape::Shape ( std::vector< std::string >  shape)
explicit

Take in an array of lines and right-pad the shorter ones with ' ' to the width of the longest line.

Definition at line 9 of file shape.cpp.

Member Function Documentation

◆ charAt()

char Shape::charAt ( int  col,
int  row 
) const

Fetch the character at the given coordinate pair.

Parameters
col0-based column (x) index
row0-based row (y) index
Returns
character at the given position
Exceptions
std::out_of_rangeif the row or column is out of bounds (negative or too large)

Definition at line 33 of file shape.cpp.

◆ height()

int Shape::height ( ) const
Returns
the height of the bounding box

Definition at line 31 of file shape.cpp.

◆ width()

int Shape::width ( ) const
Returns
the width of the bounding box (0 if the height is 0)

Definition at line 29 of file shape.cpp.


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