|
4 | 4 | from ..utils.populations import country_population |
5 | 5 |
|
6 | 6 |
|
| 7 | +class Location: |
| 8 | + def __init__( |
| 9 | + self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered, |
| 10 | + ): # pylint: disable=too-many-arguments |
| 11 | + # General info. |
| 12 | + self.id = id |
| 13 | + self.country = country.strip() |
| 14 | + self.province = province.strip() |
| 15 | + self.coordinates = coordinates |
| 16 | + |
| 17 | + # Last update. |
| 18 | + self.last_updated = last_updated |
| 19 | + |
| 20 | + # Statistics. |
| 21 | + self.confirmed = confirmed |
| 22 | + self.deaths = deaths |
| 23 | + self.recovered = recovered |
| 24 | + |
| 25 | + def add(self, location): |
| 26 | + pass |
| 27 | + |
| 28 | + def remove(self, location): |
| 29 | + pass |
| 30 | + |
| 31 | + def country_code(self): |
| 32 | + pass |
| 33 | + |
| 34 | + def country_population(self): |
| 35 | + pass |
| 36 | + |
| 37 | + def serialize(self): |
| 38 | + pass |
| 39 | + |
| 40 | + |
| 41 | +class Province(Location): |
| 42 | + countries = None |
| 43 | + |
| 44 | + def __init__( |
| 45 | + self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered, |
| 46 | + ): # pylint: disable=too-many-arguments |
| 47 | + # General info. |
| 48 | + self.id = id |
| 49 | + self.country = country.strip() |
| 50 | + self.province = None |
| 51 | + self.coordinates = coordinates |
| 52 | + |
| 53 | + # Last update. |
| 54 | + self.last_updated = last_updated |
| 55 | + |
| 56 | + # Statistics. |
| 57 | + self.confirmed = confirmed |
| 58 | + self.deaths = deaths |
| 59 | + self.recovered = recovered |
| 60 | + self.countries = [] |
| 61 | + |
| 62 | + def add(self, location): |
| 63 | + self.countries.append(location) |
| 64 | + |
| 65 | + def remove(self, location): |
| 66 | + self.countries.remove(location) |
| 67 | + |
| 68 | + def country_code(self): |
| 69 | + countries_code = [] |
| 70 | + for i in countries |
| 71 | + countries_code.append(countries.country_code(i)) |
| 72 | + return countries_code |
| 73 | + |
| 74 | + def country_population(self): |
| 75 | + countries_population = 0 |
| 76 | + for i in countries |
| 77 | + countries_population=countries_population+ country_population(i) |
| 78 | + return countries_population |
| 79 | + |
| 80 | + def serialize(self): |
| 81 | + for i in countries |
| 82 | + i.serialize() |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
7 | 87 | # pylint: disable=redefined-builtin,invalid-name |
8 | | -class Location: # pylint: disable=too-many-instance-attributes |
| 88 | +class Country(Location): # pylint: disable=too-many-instance-attributes |
9 | 89 | """ |
10 | 90 | A location in the world affected by the coronavirus. |
11 | 91 | """ |
|
0 commit comments