fixed nce property

This commit is contained in:
Marco Zeisler 2021-05-15 16:43:22 +02:00
parent 16c715c774
commit 6fcbb12693

View File

@ -38,8 +38,8 @@ class Vehicle:
@property @property
def nce(self): def nce(self):
nce = self._nce_happened nce = self._nce_happened
if nce: if not nce:
if NCE_KM >= self._driven_kms: if self._driven_kms >= NCE_KM:
nce = True nce = True
self._nce_happened = nce self._nce_happened = nce
self.velocity = 0 self.velocity = 0
@ -106,6 +106,6 @@ class Vehicle:
if __name__ == "__main__": if __name__ == "__main__":
v1 = Vehicle(vin='SB164ABN1PE082986') v1 = Vehicle(vin='SB164ABN1PE082986')
v1.start_driving() v1.start_driving()
print(v1.gps_location, v1.driven_kms) while True:
print(v1.gps_location, v1.driven_kms, v1.nce)
time.sleep(1) time.sleep(1)
print(v1.gps_location, v1.driven_kms)