Aufgaben aus dem Praktikum 4

This commit is contained in:
naimabannert committed 2026-11-05 11:31:32 +01:00
commit d0300ed30f
9 files changed
+287

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
class Particle:
def __init__(self, position, velocity=(0, 0), acceleration=(0, 0)):
self.position = position
self.velocity = velocity
self.acceleration = acceleration
self.history = []
def update(self):
self.history.append(self)
new_velocity = (self.velocity[0] + self.acceleration[0],
self.velocity[1] + self.acceleration[1])
new_position = (self.position[0] + new_velocity[0],
self.position[1] + new_velocity[1])
return Particle(new_position, new_velocity, self.acceleration)
def undo(self):
if self.history:
return self.history.pop()
return self