def test_to_string(self): fuel = Fuel(0.55) self.assertEqual("55%", str(fuel)) fuel = Fuel(0.06) self.assertEqual("6%", str(fuel)) fuel = Fuel(1.0) self.assertEqual("100%", str(fuel))
def __init__( self, licence_plate: str, size: Union[SML, LRG], fuel: Dict[str, Union[int, float]], ) -> None: self.licence_plate = licence_plate self.size = size self.full_capacity = fuel.get("capacity") self.fuel = Fuel(fuel.get("level")) self.employee = None
def load(self): station = None with open("data.json") as f: d = json.load(f) fuelList = list() for f in d["fuel"]: fuelList.append(Fuel(f["name"], f["tank"])) station = Station(d["name"]) station.__fuelList__ = fuelList return station
def add_Fuel(self, fuel_prop_w, fuel_prop_a1, fuel_prop_a2, fuel_prop_a3, fuel_prop_a4, temp_cool_F, packing_fraction, dir_name): pf = packing_fraction # 0.6 nominal pf in Mk1, 0.7405 maximum attainable packing fraction in a FCC lattice self.FuelW = Fuel(fuel_prop_w, temp_cool_F, dir_name, name='wall', packing_fraction=pf) self.FuelA1 = Fuel(fuel_prop_a1, temp_cool_F, dir_name, name='act1', packing_fraction=pf) self.FuelA2 = Fuel(fuel_prop_a2, temp_cool_F, dir_name, name='act2', packing_fraction=pf) self.FuelA3 = Fuel(fuel_prop_a3, temp_cool_F, dir_name, name='act3', packing_fraction=pf) self.FuelA4 = Fuel(fuel_prop_a4, temp_cool_F, dir_name, name='act4', packing_fraction=pf) self.define_FuelA1(self.FuelA1.temp, self.FuelA1.name) self.define_FuelA2(self.FuelA2.temp, self.FuelA2.name) self.define_FuelA3(self.FuelA3.temp, self.FuelA3.name) self.define_FuelA4(self.FuelA4.temp, self.FuelA4.name) self.define_FuelW(self.FuelW.temp, self.FuelW.name) self.comp_dict.update({ 'FuelW': self.FuelW, 'FuelA1': self.FuelA1, 'FuelA2': self.FuelA2, 'FuelA3': self.FuelA3, 'FuelA4': self.FuelA4 })
def stations_with_fuel_types(self, postcode): stations = self.get_stations(postcode)[:5] for station in stations: fuel_types = self.fuel_prices_single_station(station.code) # if 'errorDetails' in fuel_types.keys(): # print('This is an app that uses FREE API account from NSW government.') # print('Limit is 5 API call per minute.') # print(fuel_types['errorDetails']['message']) # print('Waiting for a minute...') # time.sleep(60) # fuel_types = self.fuel_prices_single_station(station.code) for item in fuel_types["prices"]: fuel = Fuel(item["fueltype"], self.get_fuel_name(item["fueltype"]), item["price"]) station.add_fuel_type(fuel) return stations
def optionAdd(self): print("Input fuel name") name = input() if self.__station__.isFuel(name): print('Fuel already exist') return print("Input fuel tank") tank = input() try: tank = int(tank) except ValueError: print("Tank must be a number!") return if type(tank) == int: self.__station__.addFuel(Fuel(name, tank)) print("Successfully added!") else: print("Tank must a number!")
def load(self): """ Loads the station from Json file >>> st = Station("station") >>> st.add_fuel_type(Fuel("95",20)) >>> Serialization().save(st) >>> ser = Serialization().load() >>> ser.__fuelList__.__getitem__(0).__name__ '95' >>> ser.__fuelList__.__getitem__(0).__tank__ 20 >>> ser.__name__ 'station' """ with open("data.json") as f: d = json.load(f) fuel_list = list() for f in d["fuel"]: fuel_list.append(Fuel(f["name"], f["tank"])) station = Station(d["name"]) station.__fuelList__ = fuel_list return station
def test_correctly_initialised(self): fuel = Fuel(0.55) self.assertEqual(0.55, fuel.current_level) self.assertEqual(1.75, fuel.price_per_litre)
def test_fuel_percentage(self): fuel = Fuel(0.1) self.assertEqual(10.0, fuel.fuel_percentage) fuel = Fuel(0.023) self.assertEqual(2.3, fuel.fuel_percentage)
# win = pygame.display.set_mode((500, 500)) # Задаем название окна pygame.display.set_caption("Plane Game") # Переменная типа Control control = Control() # Объекты типа Plane plane1 = Plane("yellow") plane2 = Plane("green") # Объект типа GUI gui = GUI() # Объекты типа Fuel fuels = [] for i in range(0, 2): fuels.append(Fuel()) # Объекты типа Bullet bullets = [] for i in range(0, 10): bullets.append(Bullet()) # Объекты типа Heart hearts = [] for i in range(0, 2): hearts.append(Heart()) while control.flag_game: control.Control() control.DrawBackground(win) plane1.Animation(win) plane1.Shoot(win, plane2)
def post(self): obj = request.form station.add_fuel_type(Fuel(obj["name"], int(obj["tank"]))) s.save(station) return s.load_json(), 201
def fuel_spawn(self, pos): # Creates fuel object and adds to sprite group """ Spawns fuel objects by using the position argument presented """ self.fuel = Fuel(pos) self.group.add(self.fuel)
if tela == 2: # se for a tela de jogo screen.blit(background, background_rect) # colocar o fundo na tela bullets = player.get_shots() prob = int (random.random()*40) # número aleatório de zero a 40 if prob<1: # se for menor do que 1 decoracoes.add(Decoration(imageDecoration,height,width)) # adiciona uma sprite de casa prob = int(random.random() * 250) # número aleatório de zero a 250 if prob < (1 + player.points / 100): # se for menor do que 1 acrescido de uma parcela dos pontos enemies.add(Enemy(imageEnemy,height)) # adiciona uma sprite de inimigo prob2 = int(random.random() * (100 + player.points / 20)) # número aleatório de zero a 100 acrescido de uma parcela dos pontos if prob2 < 1: # se for menor do que 1 fuels.add(Fuel(imageFuel,height)) # adiciona uma sprite de gasolina fuels.draw(screen) # fuels.update() # bullets.draw(screen) # bullets.update() # enemies.draw(screen) # desenha na tela as sprites criadas enemies.update() # decoracoes.draw(screen) # decoracoes.update() # player_group.draw(screen) # player.update() # if player.alive == False: # se o jogador não estiver vivo screen.fill((0,0,0)) tela = 3 # tela de game over
def create_fuel(self): fuel = Fuel(self) self.fuel_group.add(fuel)