Last active
          March 18, 2019 20:42 
        
      - 
      
 - 
        
Save berinhard/3bef4af4b1fc40864d72a941d4257cba to your computer and use it in GitHub Desktop.  
    Exemplo 002
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Posicao(): | |
| def __init__(self, lat, lng): | |
| self.set_lat(lat) | |
| self.set_lng(lng) | |
| def get_lat(self): | |
| return self.__lat | |
| def set_lat(self, value): | |
| if not -90 <= value <= 90: | |
| raise ValueError("Latitude inválida") | |
| self.__lat = value | |
| def get_lng(self): | |
| return self.__lng | |
| def set_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 | |
| p1 = Posicao(12.0123, 36.12313) | |
| p2 = Posicao(12.5123, 34.00000) | |
| dist = distancia(p1, p2) | |
| direcao = direcao(p1, p2) | |
| print(f"Distância {p1} até {p2} é de {dist}") | |
| print(f"Direção de {p1} até {p2} é de {direcao} graus") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment