1+ """app.coordinates.py"""
2+ from abc import ABCMeta , abstractmethod
3+
4+
5+ class Location (metaclass = ABCMeta ):
6+
7+ def __init__ (self , latitude , longitude ):
8+ """implement"""
9+
10+ def serialize (self ):
11+ """implement"""
12+
13+ def __str__ (self ):
14+ """implement"""
15+
16+ class Coordinates (Location ):
17+ """
18+ A position on earth using decimal coordinates (latitude and longitude).
19+ """
20+
21+ def __init__ (self , latitude , longitude ):
22+ self .latitude = latitude
23+ self .longitude = longitude
24+
25+
26+ def serialize (self ):
27+ """
28+ Serializes the coordinates into a dict.
29+
30+ :returns: The serialized coordinates.
31+ :rtype: dict
32+ """
33+ return {"latitude" : self .latitude , "longitude" : self .longitude }
34+
35+ def __str__ (self ):
36+ return "lat: %s, long: %s" % (self .latitude , self .longitude )
37+
38+
39+ class history (Location ):
40+ def __init__ (self , latitude , longitude ):
41+ self .latitude = latitude
42+ self .longitude = longitude
43+ self .hisLocations = []
44+
45+ def add (self , hisLocation ):
46+ self .hisLocations .append (hisLocation )
47+ self .latitude += hisLocation .latitude
48+ self .longitude += hisLocation .longitude
49+
50+
51+ def serialize (self ):
52+ for hisLocation in self .hisLocations :
53+ hisLocation .serialize
54+ return {"Total longitude" : self .longitude , "Total latitude" : self .latitude }
55+
56+ def __str__ (self ):
57+ return "lat: %s, long: %s" % (self .latitude , self .longitude )
0 commit comments