Example #1
0
 def test_Square(self):
     rect = rectangles.Square(2)
     data = rect.summary()
     self.assertEqual(4.,data['area'])
     self.assertEqual(8.,data['perimeter'])
Example #2
0
# coding: utf8
import rectangles
import parallelograms
import circle
import triangle
import pygame
import sys

pygame.init()

# creating objects
rectangle1 = rectangles.Rectangle(95, 130)
square1 = rectangles.Square(90)
parallelogram1 = parallelograms.Parallelogram(150, 100, 45)
diamond1 = parallelograms.Diamond(100, 60)
triangle1 = triangle.Triangle(100, 120, 110)
circle1 = circle.Circle(50)

print(circle1.area)
print(triangle1.perimeter)

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit(0)

    # drawing objects
    square1.draw()
    circle1.draw()
    diamond1.draw()
    parallelogram1.draw()
Example #3
0
# coding: utf8
import rectangles

square2 = rectangles.Square(2)

print(square2.summary())

import triangle

triangle = triangle.Triangle(2, 4, 4)
print(triangle.summary())
Example #4
0
import triangle
import circle

#Maths
import matplotlib.pyplot as plt
import numpy as np

#Data
R = 1
a = 1
b = 2
k = np.pi / 3

#Shapes
r2 = rectangles.Rectangle(a, b)  #rectangle
s2 = rectangles.Square(a)  #square
p2 = paralelogram.Parallelogram(a, b, k)  #parallelogram
d2 = paralelogram.Dimond(a, k)  ##dimond
t2 = triangle.Triangle(a, b, k)  #triangle
c2 = circle.Circle(R)  #circle

if k > np.pi / 2:
    print("There is no dimond, rectangle and square with such an angle")
    # parallelogram
    plt.plot([0, b], [0, 0])
    plt.plot([np.cos(k) * a, b + np.cos(k) * a],
             [np.sin(k) * a, np.sin(k) * a])
    plt.plot([0, np.cos(k) * a], [0, np.sin(k) * a])
    plt.plot([b, b + np.cos(k) * a], [0, np.sin(k) * a])
    plt.title("Parallelogram")
    plt.show()