Skip to content

๐Ÿ“˜ Usage Guide

This guide explains how to use the Polygon Area Calculator to work with rectangles and squares using Python.


๐Ÿงฑ Creating Shapes

Rectangle

from polygon_calculator import Rectangle

rect = Rectangle(10, 5)

Square

from polygon_calculator import Square

sq = Square(9)

Both classes store width and height internally.
Square ensures both values always remain equal.


โž• Setting Dimensions

Rectangle

rect.set_width(12)
rect.set_height(4)

Square

sq.set_side(6)
# or
sq.set_width(6)
sq.set_height(6)

๐Ÿ“ Getting Measurements

Area

rect.get_area()      # width * height
sq.get_area()

Perimeter

rect.get_perimeter()
sq.get_perimeter()

Diagonal

rect.get_diagonal()
sq.get_diagonal()

๐Ÿ–ผ๏ธ Generating Shape Pictures

You can generate ASCII-based visual representations:

print(rect.get_picture())

Example output:

**********
**********
**********

Shapes larger than 50 in width or height return:

Too big for picture.

๐Ÿ“ฆ Packing Shapes Inside Each Other

Determine how many times one shape fits inside another:

rect = Rectangle(16, 8)
sq = Square(4)

rect.get_amount_inside(sq)   # returns 8

This calculates:

(rect.width // sq.width) * (rect.height // sq.height)

๐Ÿ“„ String Representations

Each class has a descriptive __str__:

print(Rectangle(3, 6))
# Rectangle(width=3, height=6)

print(Square(5))
# Square(side=5)

๐Ÿงช Next Steps

Explore:

  • API Reference for full method descriptions
  • Examples for real-world usage

Happy coding! ๐Ÿš€