Skip to content

Instantly share code, notes, and snippets.

@berinhard
Created March 18, 2019 20:42
Show Gist options
  • Save berinhard/9eb69f44897f634193b612ef08976cf5 to your computer and use it in GitHub Desktop.
Save berinhard/9eb69f44897f634193b612ef08976cf5 to your computer and use it in GitHub Desktop.
Exemplo 002 pythônico
class Posicao():
def __init__(self, lat, lng):
self.lat, self.lng = lat, lng
@property
def lat(self):
return self._lat
@lat.setter
def lat(self, value):
if not -90 <= value <= 90:
raise ValueError("Latitude inválida")
self._lat = value
@property
def lng(self):
return self._lng
@lng.setter
def lng(self, value):
if not -180 <= value <= 180:
raise ValueError("Longitude inválida")
self._lng = value
def distancia(pos_1, pos_2):
#### implementação do cálculo de distância
def direcao(pos_1, pos_2):
#### implementação do cálculo de direção
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment