Ejemplo n.º 1
0
 def _add_flight(self, plane_id, date_time, passengers, cargo):
     Plane.flight(plane_id=plane_id,
                  date_time=date_time,
                  passengers=passengers,
                  cargo=cargo)
     payment = self.PASSENGER_PAYMENT * passengers + self.CARGO_TON_PAYMENT * cargo
     self._get_money(payment, "flight of plane # {}".format(plane_id))
Ejemplo n.º 2
0
def init_planes(number_of_planes):
    """
    Make sure that the planes do not start in the same position.
    :return:
    """
    planes_list = []
    while number_of_planes > 0:
        plane = Plane(0, 0, rand=True)
        x_plane, y_plane = plane.get_position()
        print(len(planes_list))
        if not plane.check_for_collisions(
                planes_list, x_coor=x_plane, y_coor=y_plane):
            planes_list.append(plane)
            number_of_planes -= 1
    return planes_list
Ejemplo n.º 3
0
 def buy_plane(self, plane_id):
     if self.can_buy_plane(plane_id):
         price = Plane.price_market_plane(plane_id)
         self._pay_money(price, "purchase plane # {}".format(plane_id))
         self._add_plane(plane_id)
     else:
         raise ValueError("No money - no honey")
Ejemplo n.º 4
0
    def __init__(self, args):
        super().__init__(args.NUM_PLANES)

        self.grid = generateGrid(args.GRID_SIZE[0], args.GRID_SIZE[1],
                                 args.LOCATION)
        self.args = args
        self.map = []
        self.complete = Queue(args.NUM_PLANES)
        for id in range(args.NUM_PLANES):
            newplane = Plane(id, args)
            self.map.append(newplane.telemetry())
            assert (self.map[-1] != None)
            self.put(newplane)

        self.run()
        self.report()
Ejemplo n.º 5
0
    def plane(self, correct_pos=None, *args):
        """
        args: [correct_pos] - creates a plane with\
 correct position set to correct_pos
        """
        try:
            position = float(correct_pos)
        except TypeError:
            position = 0
        self.namespace['plane'] = Plane(position)
Ejemplo n.º 6
0
 def simulator(self, *args):
     """
     creates new simulator
     """
     self.namespace['simulator'] = PlaneSimulator(
             self.namespace.setdefault('plane', Plane()))
Ejemplo n.º 7
0
 def planes_stat(self):
     return Plane.planes_stat(airline_id=self.airline_id)
Ejemplo n.º 8
0
 def market_planes(self):
     return Plane.market_planes()
Ejemplo n.º 9
0
 def cargo_planes(self):
     return Plane.cargo_planes(airline_id=self.airline_id)
Ejemplo n.º 10
0
 def passenger_planes(self):
     return Plane.passenger_planes(airline_id=self.airline_id)
Ejemplo n.º 11
0
 def planes(self):
     return Plane.planes(airline_id=self.airline_id)
Ejemplo n.º 12
0
 def flights(self):
     return Plane.flights(airline_id=self.airline_id)
Ejemplo n.º 13
0
 def sell_plane(self, plane_id):
     price = Plane.price_own_plane(plane_id)
     self._del_plane(plane_id)
     self._get_money(price, "sold plane # {}".format(plane_id))
Ejemplo n.º 14
0
 def can_buy_plane(self, plane_id):
     settings.logger.info(
         "Request for allowing to buy plane #{}".format(plane_id))
     return self.balance >= Plane.price_market_plane(plane_id)
Ejemplo n.º 15
0
 def market_available_planes(self):
     return Plane.market_available_planes(airline_id=self.airline_id)