コード例 #1
0
def make_power_source():
    return electric_grid.ElectricGrid([
        coal.OldCoalPowerPlant(),
        coal.NewCoalPowerPlant(),
        nuclear.OldNuclearReactor(),
        nuclear.NewNuclearReactor(),
        nuclear.OldNuclearPowerPlant(),
        nuclear.NewNuclearPowerPlant(),
    ])
コード例 #2
0
def create_power_source(source_type):
    if source_type == 'old coal':
        return coal.OldCoalPowerPlant()
    elif source_type == 'new coal':
        return coal.NewCoalPowerPlant()
    elif source_type == 'old nuclear reactor':
        return nuclear.OldNuclearReactor()
    elif source_type == 'new nuclear reactor':
        return nuclear.NewNuclearReactor()
    elif source_type == 'old nuclear plant':
        return nuclear.OldNuclearPowerPlant()
    elif source_type == 'new nuclear plant':
        return nuclear.NewNuclearPowerPlant()

    raise ValueError(f'Unknown power source type: {source_type}')