Created
December 5, 2021 10:41
-
-
Save timurbakibayev/e7062e125063763c1bcaf7ffef993f1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
from gasoline.gasoline import GasPortion | |
from gaspump.gaspump import GasPump | |
@dataclass | |
class Pedal: | |
connected_gas_pump: GasPump | |
def press( | |
self, | |
how_hard: float, | |
seconds: float, | |
) -> GasPortion: | |
if seconds < 0: | |
raise ValueError("No negative time period allowed") | |
how_hard = max(0, how_hard) | |
how_hard = min(1, how_hard) | |
return self.connected_gas_pump.apply( | |
voltage=12*how_hard, | |
seconds=seconds, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment