Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- class punct:
- def __init__(self, xx, yy):
- self.__xx = xx
- self.__yy = yy
- def __repr__(self):
- return 'Punctul a este {} si punctul b este{}'.format(self.xx, self.yy)
- def __eq__(self, other):
- if self.__xx == other.__xx and self.__yy == other.__yy:
- return False
- else:
- return True
- def distanta(self, other):
- dis = math.sqrt((self.__xx - other.__xx) ** 2 + (self.__xx - other.__yy) ** 2)
- return dis
- class segment:
- def __init__(self, a, b):
- self.__a = a
- self.__b = b
- def __repr__(self):
- return 'Segmentul a are: {} iar segmentul b are: {}'.format(self.__a, self.__b)
- def intersectie(self, other):
- pass
- p1 = punct(2, 3)
- p2 = punct(3, 5)
- D = p1.distanta(p2)
- print(D)
- class Station:
- def __init__(self,n,c,x,y):
- self.nume=n
- self.cod=c
- self.x=x
- self.y=y
- def __repr__(self):
- return 'Sunteti in statia {}'.format(self.nume)
- @staticmethod
- def getStations():
- listaStatie=[]
- fisier=open ("stationCode.txt","r")
- # r = read, w = write , a = append
- for line in fisier:
- pSpatiu = line.index(" ")
- cod = line[ :pSpatiu]
- denumire = line[pSpatiu+1:]
- statie=Station(denumire,cod,None,None)
- listaStatie.append(statie)
- listaCoordonate=[]
- fisier=open("stationCord.txt","r")
- for line in fisier:
- pSpatiu = line.index(" ")
- pSpatiu2 = line.index (" ",pSpatiu+1)
- cod = line [ :pSpatiu]
- x = line[pSpatiu+1:pSpatiu2]
- y = line[pSpatiu2:]
- statie=Station
- listaCoordonate.append(statie)
- print(cod, end =" ")
- print(x, end=" ")
- print(y, end=" ")
- Station.getStations()
- # apel de functie statica
Advertisement
Add Comment
Please, Sign In to add comment