commit
404a249757
|
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (dieselbestellrechner)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/dieselbestellrechner.iml" filepath="$PROJECT_DIR$/.idea/dieselbestellrechner.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
import json
|
||||
from tank import Tank
|
||||
|
||||
configfile = "config.json"
|
||||
|
||||
|
||||
class App:
|
||||
|
||||
def __init__(self):
|
||||
self._tanks = []
|
||||
self._refuel_max = None
|
||||
self._refuel_goal = None
|
||||
self.load_preferences()
|
||||
self.calculate_refuel()
|
||||
|
||||
def load_preferences(self):
|
||||
with open(configfile, 'r') as json_file:
|
||||
json_row = json.load(json_file)
|
||||
for t in json_row['tanks']:
|
||||
tank = Tank(t['name'], t['total'], t['actual'], t['dead'])
|
||||
self._tanks.append(tank)
|
||||
self._refuel_max = json_row["refuel"]["max"]
|
||||
self._refuel_goal = json_row["refuel"]["goal"]
|
||||
|
||||
def calculate_refuel(self):
|
||||
total_empty_space = 0
|
||||
for tank in self._tanks:
|
||||
total_empty_space += tank.refuel_volume
|
||||
print("total empty space: ", total_empty_space)
|
||||
if total_empty_space < self._refuel_max:
|
||||
print("total empty space is lower as refuel")
|
||||
return
|
||||
elif self._refuel_max > total_empty_space - self._refuel_goal:
|
||||
print("maybe is empty space to low")
|
||||
return
|
||||
else:
|
||||
# todo: formel ausdenken
|
||||
portion = self._refuel_max // len(self._tanks)
|
||||
print("portion", portion)
|
||||
portion_ok = True
|
||||
for tank in self._tanks:
|
||||
if tank.refuel_volume < portion:
|
||||
print("tank ", tank.name, " empty space is to low")
|
||||
portion_ok = False
|
||||
if portion_ok:
|
||||
print("portion is ok")
|
||||
|
||||
@property
|
||||
def tanks(self):
|
||||
return self._tanks
|
||||
|
||||
def refuel(self, tank: Tank, portion):
|
||||
""" just to test """
|
||||
tank.refuel_volume()
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"tanks": [
|
||||
{
|
||||
"name": "Tank 1",
|
||||
"total": 30000,
|
||||
"actual": 10000,
|
||||
"dead": 2000
|
||||
},
|
||||
{
|
||||
"name": "Tank 2",
|
||||
"total": 35000,
|
||||
"actual": 15000,
|
||||
"dead": 2000
|
||||
}
|
||||
],
|
||||
"refuel": {
|
||||
"max": 33000,
|
||||
"goal": -6000
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import flet as ft
|
||||
from app import App
|
||||
|
||||
|
||||
def main(page: ft.Page):
|
||||
name_row = ft.Row(controls=[ft.Text(tank.name) for tank in app.tanks])
|
||||
page.add(name_row)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = App()
|
||||
ft.app(target=main)
|
||||
Binary file not shown.
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
|
||||
class Tank:
|
||||
|
||||
def __init__(self, name, total, dead, act_in=None):
|
||||
self._name = name
|
||||
self._total = total
|
||||
self._dead = dead
|
||||
self._act_in = act_in
|
||||
|
||||
def _read_act_in(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def total_volume(self):
|
||||
return self._total
|
||||
|
||||
@property
|
||||
def actual_volume(self):
|
||||
return self._act_in
|
||||
|
||||
@property
|
||||
def empty_volume(self):
|
||||
return self._total - self._act_in
|
||||
|
||||
@property
|
||||
def dead_volume(self):
|
||||
return self._dead
|
||||
|
||||
@property
|
||||
def refuel_volume(self):
|
||||
return self._total - self._act_in - self._dead
|
||||
Loading…
Reference in New Issue