|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
#coding:utf-8
|
|
|
|
|
import statistics
|
|
|
|
|
import custom_exception
|
|
|
|
|
from custom_exception.nothing_to_compare_error import *
|
|
|
|
|
|
|
|
|
|
class Boat:
|
|
|
|
|
def __init__(self, boat_id: str, name: str, sismer_id: str, url: str, avatar:str , temperatures: list, positions: list):
|
|
|
|
@ -13,15 +13,21 @@ class Boat:
|
|
|
|
|
self.positions = positions
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return f"{self.name}"
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
|
if other is None:
|
|
|
|
|
return False
|
|
|
|
|
if not isinstance(other, self.__class__):
|
|
|
|
|
return False
|
|
|
|
|
return self.boat_id == other.boat_id
|
|
|
|
|
|
|
|
|
|
def get_temp_mean(self):
|
|
|
|
|
return statistics.mean(self.temperatures)
|
|
|
|
|
def get_northiest_coords(self):
|
|
|
|
|
if len(self.positions) == 0:
|
|
|
|
|
raise custom_exception.NothingToComapreError(f"{self.name} must have coords to compare")
|
|
|
|
|
raise NothingToCompareError(f"{self.name} must have coords to compare")
|
|
|
|
|
best = self.positions[0]
|
|
|
|
|
for position in self.positions:
|
|
|
|
|
if position.is_northiest_than(best):
|
|
|
|
|
if position.is_norther_than(best):
|
|
|
|
|
best = position
|
|
|
|
|
return best
|
|
|
|
|
|
|
|
|
|