File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 11"""app.coordinates.py"""
2+
3+
24class Coordinates :
35 """
46 A position on earth using decimal coordinates (latitude and longitude).
57 """
8+
69 def __init__ (self , latitude , longitude ):
710 self .latitude = latitude
811 self .longitude = longitude
912
1013 def serialize (self ):
1114 """
1215 Serializes the coordinates into a dict.
16+
1317 :returns: The serialized coordinates.
1418 :rtype: dict
1519 """
Original file line number Diff line number Diff line change 1414def data_source (source ):
1515 """
1616 Retrieves the provided data-source service.
17+
1718 :returns: The service.
1819 :rtype: LocationService
1920 """
Original file line number Diff line number Diff line change 2121)
2222def test_countries_country_name__country_code (country_name , expected_country_code ):
2323 assert countries .country_code (country_name ) == expected_country_code
24+
25+ __shared_instance = None
26+ @staticmethod
27+ def getInstance ():
28+ """Static Access Methods """
29+ if Country .__shared_instance == None :
30+ Country ()
31+ return Country .__shared_instance
32+
33+ def __init__ (self ) -> None :
34+ """ Virtual Private Constructor"""
35+ if Country .__shared_instance != None :
36+ raise Exception ("Singleton Class already initialized. Please use getInstance()" )
37+ else :
38+ Country .__shared_instance = self
You can’t perform that action at this time.
0 commit comments