Advertisement
cicwak

Untitled

Jul 7th, 2022
809
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None
  1.  
  2. class People:
  3.     def __init__(self, name: str):
  4.         self.name = name
  5.         self.happy = 100
  6.  
  7.     def __str__(self):
  8.         return "\n" + str(self.name)
  9.  
  10.  
  11. class House:
  12.     def __init__(self):
  13.         self.tenants = []  # жильцы
  14.  
  15.     def add_tenants(self, tenant: People):
  16.         self.tenants.append(tenant)
  17.  
  18.     def get_tenants(self):
  19.         return self.tenants
  20.  
  21.  
  22. house = House()
  23. wife = People(name="Kiriena")
  24. husband = People(name="Kostya")
  25.  
  26. house.add_tenants(husband)
  27. house.add_tenants(wife)
  28.  
  29. print(*house.get_tenants())
  30.  
Advertisement
RAW Paste Data Copied
Advertisement