Ответ:
class Worker:
def __init__(self, name, position):
self.name = name
self.position = position
class Office:
def __init__(self, name):
self.workers = []
def add_worker(self, worker):
self.workers.append(worker)
def print_workers(self):
print("Workers in", self.name)
for worker in self.workers:
print(worker.name, "-", worker.position)
office1 = Office("Office 1")
office2 = Office("Office 2")
worker1 = Worker("John", "Manager")
worker2 = Worker("Jane", "Developer")
worker3 = Worker("Bob", "Designer")
office1.add_worker(worker1)
office1.add_worker(worker2)
office2.add_worker(worker3)
office1.print_workers()
office2.print_workers()
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
class Worker:
def __init__(self, name, position):
self.name = name
self.position = position
class Office:
def __init__(self, name):
self.name = name
self.workers = []
def add_worker(self, worker):
self.workers.append(worker)
def print_workers(self):
print("Workers in", self.name)
for worker in self.workers:
print(worker.name, "-", worker.position)
office1 = Office("Office 1")
office2 = Office("Office 2")
worker1 = Worker("John", "Manager")
worker2 = Worker("Jane", "Developer")
worker3 = Worker("Bob", "Designer")
office1.add_worker(worker1)
office1.add_worker(worker2)
office2.add_worker(worker3)
office1.print_workers()
office2.print_workers()
Что делать с этим?