Exemplo n.º 1
0
def test_add_circle():
    name_1 = 'MyTest1'
    r1 = 4
    name_2 = 'MyTest2'
    r2 = 7
    s1 = pi * r1**2
    s2 = pi * r2**2
    c1 = Circle(name_1, r1)
    c2 = Circle(name_2, r2)
    assert isclose(c1.add_area(c2), s1 + s2)
Exemplo n.º 2
0
def main():
    with open('file.txt', 'r') as f:
        array = f.readlines()

    list = []
    for line in array:
        if line[0] == 'T':
            figure = Triangle(line)
        elif line[0] == 'R':
            figure = Rectangle(line)
        elif line[0] == 'C':
            figure = Circle(line)
        else:
            raise Exception("wrong figure")

        list.append(figure)

    list.sort(key=lambda el: el.square())

    for el in list:
        print(el)
Exemplo n.º 3
0
font = None
menu = []
# menu = [
#     (
#         Rectangle(20 - 10, 100 + 60*i - 40, width=600, height=50, fill=True),
#         font.text(20, 100 + 60*i, v)# Text(20, 100 + 60*i, text=v, font=b"Ubuntu-R.ttf")
#     ) for i, v in enumerate(menu_str)
# ]

# for item in menu:
#     item[0].setColor(20, 20, 20)

menu_rect = Rectangle(0, 0, width=600, height=50)
menu_rect.setColor(150, 150, 30)

menu_mouse = Circle(0, 0, radius=10)


def gameMenu(eel):
    global current_state

    for item in menu:
        for shape in item:
            shape.drawTo(canvases[0])

    menu_mouse.pos = eel.mouse
    for i, item in enumerate(menu):
        if menu_mouse.collidesWith(item[0]):

            menu_rect.pos = item[0].pos
            menu_rect.drawTo(canvases[0])
Exemplo n.º 4
0
from figure import Rectangle, Circle

r = Rectangle(10, 5)
c = Circle(5)

print("r.getArea=", r.getArea())
print("c.getArea=", f"{c.getArea():.2f}")
Exemplo n.º 5
0
def test_circle_init():
    name = 'MyTest'
    r = 5
    c = Circle(name, r)
    assert c.name == name
    assert c.r == r
Exemplo n.º 6
0
def test_add_circle_negative():
    name_1 = 'MyTest1'
    r = 2.4
    c = Circle(name_1, r)
    with pytest.raises(TypeError):
        c.add_area(123)
Exemplo n.º 7
0
def test_circle_perimeter():
    name = 'MyTest'
    r = 7
    p = 2 * pi * r
    c = Circle(name, r)
    assert isclose(p, c.perimeter)
Exemplo n.º 8
0
def test_circle_area():
    name = 'MyTest'
    r = 6
    s = pi * r**2
    c = Circle(name, r)
    assert isclose(s, c.area)