parent
c169660a24
commit
e4a1805066
@ -0,0 +1,5 @@
|
|||||||
|
#coding:utf-8
|
||||||
|
|
||||||
|
class BoatsLoader:
|
||||||
|
def load_boats(year: int):
|
||||||
|
pass
|
@ -1,10 +0,0 @@
|
|||||||
#! encode:utf8
|
|
||||||
|
|
||||||
import requests
|
|
||||||
|
|
||||||
class DataLoader:
|
|
||||||
def load_from_url(self, url):
|
|
||||||
data = requests.get(url)
|
|
||||||
if(data.status_code != 200):
|
|
||||||
raise Exception(f"Error {data.status_code}")
|
|
||||||
return data
|
|
@ -0,0 +1,22 @@
|
|||||||
|
#coding:utf-8
|
||||||
|
|
||||||
|
from boats_loader import BoatsLoader
|
||||||
|
|
||||||
|
class Fleet:
|
||||||
|
def __init__(self, year: int, loader: BoatsLoader):
|
||||||
|
self.boats = loader.load_boats(year)
|
||||||
|
|
||||||
|
def get_northiest(self):
|
||||||
|
if len(self.boats) == 0:
|
||||||
|
raise Exception("No boats to compare")
|
||||||
|
best_boat = self.boats[0]
|
||||||
|
best_coords = None
|
||||||
|
for boat in self.boats:
|
||||||
|
#try:
|
||||||
|
if boat.get_northiest_coords().is_northiest_than(best_coords):
|
||||||
|
best_boat = boat
|
||||||
|
best_coords = boat.get_northiest_coords()
|
||||||
|
#except Exception as e:
|
||||||
|
# print(e)
|
||||||
|
return best_boat, best_coords
|
||||||
|
|
Loading…
Reference in new issue