code styling: add comments and fix pep8
This commit is contained in:
34
classes.py
34
classes.py
@@ -1,14 +1,24 @@
|
||||
"""
|
||||
All types used in the project
|
||||
"""
|
||||
|
||||
from enum import Enum
|
||||
import math
|
||||
|
||||
|
||||
class ParsingMode(Enum):
|
||||
"""
|
||||
Used for parsing
|
||||
"""
|
||||
LOCATIONS = 1
|
||||
FLIGHTSCHEDULE = 2
|
||||
FINDCONNECTION = 3
|
||||
|
||||
|
||||
class LocationType(Enum):
|
||||
"""
|
||||
Differenciate between types of location
|
||||
"""
|
||||
LOCATION = 1
|
||||
HALTESTELLE = 2
|
||||
FLUGHAFEN = 3
|
||||
@@ -27,6 +37,10 @@ class TransportData():
|
||||
|
||||
|
||||
class TransportMethod(Enum):
|
||||
"""
|
||||
More precise methods of transportation.
|
||||
They are subgroups of TransportKind.
|
||||
"""
|
||||
WALK = TransportData(0, 4)
|
||||
CITY = TransportData(0.189, 30)
|
||||
AUTOBAHN = TransportData(0.189, 100)
|
||||
@@ -37,7 +51,8 @@ class TransportMethod(Enum):
|
||||
|
||||
class TransportKind(Enum):
|
||||
"""
|
||||
distance_penalty
|
||||
General transportation kind.
|
||||
Value: distance_penalty
|
||||
"""
|
||||
INDIVIDUAL = 0.2
|
||||
TRAIN = 0.1
|
||||
@@ -57,14 +72,20 @@ class Coordinate:
|
||||
|
||||
|
||||
class Location:
|
||||
def __init__(self, coord: Coordinate, continent: int, name: str, type: LocationType):
|
||||
def __init__(
|
||||
self,
|
||||
coord: Coordinate,
|
||||
continent: int,
|
||||
name: str,
|
||||
type: LocationType):
|
||||
self.coord = coord
|
||||
self.continent = continent
|
||||
self.name = name
|
||||
self.type = type
|
||||
|
||||
def __str__(self):
|
||||
return f"{{Location: {self.coord}, continent: {self.continent}, name: {self.name}, type: {self.type}}}"
|
||||
return f"{{Location: {self.coord}, continent: {self.continent}, \
|
||||
name: {self.name}, type: {self.type}}}"
|
||||
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
@@ -88,13 +109,18 @@ class Location:
|
||||
|
||||
|
||||
class DataSet:
|
||||
"""
|
||||
Represent the parsed data
|
||||
"""
|
||||
|
||||
def __init__(self, locations: dict, flights: dict, connection: tuple):
|
||||
self.locations = locations
|
||||
self.flights = flights
|
||||
self.connection = connection
|
||||
|
||||
def __str__(self):
|
||||
return f"locations: {self.locations}, flights: {self.flights}, connection: {self.connection}"
|
||||
return f"locations: {self.locations}, flights: {self.flights}, \
|
||||
connection: {self.connection}"
|
||||
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
Reference in New Issue
Block a user