Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #1749

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added app/cinema/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions app/cinema/bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class CinemaBar:

@staticmethod
def sell_product(customer: "Customer", product: str) -> None:
print(f"Cinema bar sold {product} to {customer}.")


class Customer:

def __init__(self, name: str, food: str) -> None:
self.name = name
self.food = food

def __str__(self) -> str:
return self.name

def watch_movie(self) -> None:
print(f"Customer {self.name} is watching a movie")


cb = CinemaBar()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CinemaBar class is instantiated, but since sell_product is a static method, you don't need to create an instance of CinemaBar to call it. You can call it directly using CinemaBar.sell_product(customer=customer, product=customer.food).

customer = Customer("Bob", "popcorn")
cb.sell_product(customer=customer, product=customer.food)
27 changes: 27 additions & 0 deletions app/cinema/hall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from app.cinema.bar import Customer


class CinemaHall:

def __init__(self, number: int) -> None:
self.number: int = number

def movie_session(self,
movie_name: str,
customers: list["Customer"],
cleaning_staff: "Cleaner"
) -> None:
print(f'"{movie_name}" started in hall number {self.number}.')
for customer in customers:
customer.watch_movie(movie_name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The watch_movie method in the Customer class does not accept any parameters, but here it is called with movie_name as an argument. You should remove the argument to match the method definition: customer.watch_movie().

Comment on lines +16 to +17

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The watch_movie method is being called with an argument (movie_name), but it does not accept any parameters. Remove the argument to match the method's definition.

print(f'"{movie_name}" ended.')
cleaning_staff.clean_hall(self.number)


class Cleaner:

def __init__(self, name: str) -> None:
self.name = name

def clean_hall(self, number_hall: object) -> None:
print(f"Cleaner {self.name} is cleaning hall {number_hall}.")
39 changes: 35 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# write your imports here
from app.cinema.bar import CinemaBar
from app.cinema.hall import CinemaHall
from app.people.cinema_staff import Cleaner
from app.people.customer import Customer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path from app.people.customer import Customer seems incorrect based on the current file structure. The Customer class is defined in app/cinema/bar.py, so you should import it from there: from app.cinema.bar import Customer.

from typing import List, Dict


def cinema_visit(customers: list, hall_number: int, cleaner: str, movie: str):
# write you code here
pass
def cinema_visit(customers: List[Dict[str, str]],
hall_number: int,
cleaner: str,
movie: str) -> None :
customer_objects = [Customer(name=c["name"], food=c["food"])
for c in customers]

for customer in customer_objects:
CinemaBar.sell_product(product=customer.food, customer=customer)

cinema_hall = CinemaHall(hall_number)

cleaning_staff = Cleaner(name=cleaner)

cinema_hall.movie_session(movie_name=movie, customers=customer_objects,
cleaning_staff=cleaning_staff)


if __name__ == "__main__":
customers = [
{"name": "Bob", "food": "Coca-cola"},
{"name": "Alex", "food": "popcorn"}
]
hall_number = 5
cleaner_name = "Anna"
movie = "Madagascar"
cinema_visit(customers=customers,
hall_number=hall_number,
cleaner=cleaner_name,
movie=movie)
Empty file added app/people/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions app/people/cinema_staff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Cleaner:

def __init__(self, name: str) -> None:
self.name = name

def clean_hall(self, hall_number: int) -> None:
print(f"Cleaner {self.name} is cleaning hall number {hall_number}.")
11 changes: 11 additions & 0 deletions app/people/customer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Customer:

def __init__(self, name: str, food: str) -> None:
self.name = name
self.food = food

def __str__(self) -> str:
return self.name

def watch_movie(self, movie: str) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The watch_movie method currently accepts a movie parameter. If the task requirements specify that this method should not take any parameters, you should remove the movie parameter from the method definition.

print(f'{self.name} is watching "{movie}".')