From Denim Marmoset, 10 Months ago, written in Python.
This paste is a reply to zadanie from Mungo Peafowl - view diff
Embed
Hits: 107
1. import random
2. import math
3. import turtle
4. class punkt(object):
5.     def __init__(self,x,y):
6.         self.__x=x
7.         self.__y=y
8.
9.     def getxy(self):
10.         return(self.__x,self.__y)
11.
12.     def draw(self):
13.         turtle.speed(0)
14.         turtle.up()
15.         turtle.goto(self.__x,self.__y)
16.         turtle.dot()
17.         turtle.write(turtle.pos())
18.
19. class wektor(object):
20.     def __init__(self,start,koniec):
21.         self.__start=start
22.         self.__koniec=koniec
23.
24.     def getwektor(self):
25.         return(self.__start.getxy(),self.__koniec.getxy())
26.
27.     def draww(self):
28.         turtle.up()
29.         turtle.goto(self.__start.getxy()[0],self.__start.getxy()[1])
30.         turtle.write(turtle.pos())
31.         turtle.down()
32.         turtle.goto(self.__koniec.getxy()[0],self.__koniec.getxy()[1])
33.         turtle.write(turtle.pos())
34.
35. def sortuj(list1):
36.     for i in range(1,len(list1)):
37.         key=list1[i]
38.         j=i-1
39.         while j>=0 and (list1[j].getxy()[0]>key.getxy()[0]) or (list1[i].getxy()[0]==key.getxy()[0] and list1[i].getxy()[1]>key.getxy()[1]):
40.             list1[j+1]=list1[j]
41.             j=j-1
42.         list1[j+1]=key
43.
44.
45.
46. listap = []
47. for x in range(20):
48.     a = punkt(random.randint(-300,300),random.randint(-300,300))
49.     listap.append(a)
50.
51.
52. wektory = []
53. for x in range(0,len(listap)-1):
54.     a = wektor(listap[x],listap[x+1])
55.     wektory.append(a)
56.
57. for x in wektory:
58.     x.draww()
59. turtle.done()
60.
61.
62.