Example #1
0
 def parse(text: str) -> 'Polygon':
     polygon = Polygon()
     rows = text.strip().split('\n')
     for row in rows:
         p = Point.parse(row)
         polygon._points.append(p)
     return polygon
Example #2
0
 def parse(text: str) -> 'Polygon':
     polygon = Polygon()
     rows = text.strip().split('\n')
     for row in rows:
         p = Point.parse(row)
         polygon._points.append(p)
     return polygon
Example #3
0
def main():
    NEW_POINT = 1
    MOVE_POINT = 2
    NEW_CIRCLE = 3
    EXIT = 9

    points = []
    circles = []

    choice = 0
    while choice != EXIT:
        print('Points:')
        for i, p in enumerate(points):
            print(i, p)

        print('Circles:')
        for i, c in enumerate(circles):
            print(i, c)

        print('Enter your coice:')
        print('1. Create point (x, y)')
        print('2. Move point (point-id, x, y)')
        print('3. Create circle (point-id, radius)')
        print('9. Exit')

        choice = int(input('choice? '))
        if choice == NEW_POINT:
            p = Point.parse(input('x, y? '))
            points.append(p)
        elif choice == MOVE_POINT:
            i = int(input('i? '))
            x = float(input('x? '))
            y = float(input('y? '))
            if 0 <= i < len(points):
                p = points[i]
                p.set_cartesian(x, y)
        elif choice == NEW_CIRCLE:
            i = int(input('i? '))
            r = float(input('r? '))
            if 0 <= i < len(points):
                p = points[i]
                c = Circle(p, r)
                circles.append(c)
Example #4
0
def main():
    NEW_POINT = 1
    MOVE_POINT = 2
    NEW_CIRCLE = 3
    EXIT = 9

    points = []
    circles = []

    choice = 0
    while choice != EXIT:
        print('Points:')
        for i, p in enumerate(points):
            print(i, p)

        print('Circles:')
        for i, c in enumerate(circles):
            print(i, c)

        print('Enter your coice:')
        print('1. Create point (x, y)')
        print('2. Move point (point-id, x, y)')
        print('3. Create circle (point-id, radius)')
        print('9. Exit')

        choice = int(input('choice? '))
        if choice == NEW_POINT:
            p = Point.parse(input('x, y? '))
            points.append(p)
        elif choice == MOVE_POINT:
            i = int(input('i? '))
            x = float(input('x? '))
            y = float(input('y? '))
            if 0 <= i < len(points):
                p = points[i]
                p.set_cartesian(x, y)
        elif choice == NEW_CIRCLE:
            i = int(input('i? '))
            r = float(input('r? '))
            if 0 <= i < len(points):
                p = points[i]
                c = Circle(p, r)
                circles.append(c)
Example #5
0
        for i, p in enumerate(points):
            print(i, p)

        print('Circles:')
        for i, c in enumerate(circles):
            print(i, c)

        print('Enter your coice:')
        print('1. Create point (x, y)')
        print('2. Move point (point-id, x, y)')
        print('3. Create circle (point-id, radius)')
        print('9. Exit')

        choice = int(input('choice? '))
        if choice == NEW_POINT:
            p = Point.parse(input('x, y? '))
            points.append(p)
        elif choice == MOVE_POINT:
            i = int(input('i? '))
            x = float(input('x? '))
            y = float(input('y? '))
            if 0 <= i < len(points):
                p = points[i]
                p.set_cartesian(x, y)
        elif choice == NEW_CIRCLE:
            i = int(input('i? '))
            r = float(input('r? '))
            if 0 <= i < len(points):
                p = points[i]
                c = Circle(p, r)
                circles.append(c)
Example #6
0
        for i, p in enumerate(points):
            print(i, p)
            
        print('Circles:')
        for i, c in enumerate(circles):
            print(i, c)
            
        print('Enter your coice:')
        print('1. Create point (x, y)')
        print('2. Move point (point-id, x, y)')
        print('3. Create circle (point-id, radius)')
        print('9. Exit')

        choice = int(input('choice? '))
        if choice == NEW_POINT:
            p = Point.parse(input('x, y? '))
            points.append(p)
        elif choice == MOVE_POINT:
            i = int(input('i? '))
            x = float(input('x? '))
            y = float(input('y? '))
            if 0 <= i < len(points):
                p = points[i]
                p.set_cartesian(x, y)
        elif choice == NEW_CIRCLE:
            i = int(input('i? '))
            r = float(input('r? '))
            if 0 <= i < len(points):
                p = points[i]
                c = Circle(p, r)
                circles.append(c)