r/PythonLearning • • 8h ago

Python Study Log: Day 22

Post image
2 Upvotes

2 comments sorted by

View all comments

1

u/Money_Ad_5277 2h ago

OOP. Cool!

Want to point out something:
Inheritance is wrong. Buying isn't Student nor Car

Better buying class would be

class Buying: # also, naming stuff - hard but worth it
  def __init__(self, buyer: Student, car: Car):
    self._buyer = buyer # also you could implement .copy() method
    self._car = car # .copy()
  def buyer_info(self):
    self._buyer.info()
    self._car.car_info()