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

Good #1730

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Good #1730

Show file tree
Hide file tree
Changes from all 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.
10 changes: 10 additions & 0 deletions app/cinema/bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import annotations
from app.people.customer import Customer


class CinemaBar:

@staticmethod
def sell_product(product: str, customer: Customer) -> None:
product = customer.food
Comment on lines +8 to +9

Choose a reason for hiding this comment

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

The sell_product method should use the product parameter directly instead of overwriting it with customer.food. This ensures that the method sells the product specified by the caller, not just the food associated with the customer.

Choose a reason for hiding this comment

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

The line product = customer.food is incorrect. You should use the product parameter directly instead of overwriting it with customer.food. This will ensure the correct product is sold as intended.

print(f"Cinema bar sold {product} to {customer.name}.")
20 changes: 20 additions & 0 deletions app/cinema/hall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import annotations
from app.people.customer import Customer
from app.people.cinema_staff import Cleaner


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

def movie_session(
self,
movie_name: str,
customers: Customer,

Choose a reason for hiding this comment

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

The customers parameter should be a list of Customer instances, not a single Customer instance. Update the type hint to list[Customer] to reflect this.

Choose a reason for hiding this comment

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

The customers parameter should be a list of Customer instances, not a single Customer. Change the type annotation to List[Customer] and ensure you import List from typing.

cleaner_staff: Cleaner
) -> None:
print(f'"{movie_name}" started in hall number {self.number}.')
for customer in customers:
customer.watch_movie(movie_name)
print(f'"{movie_name}\" ended.')
cleaner_staff.clean_hall(self.number)
24 changes: 20 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# write your imports here
from app.cinema.hall import CinemaHall
from app.people.cinema_staff import Cleaner
from app.people.customer import Customer
from app.cinema.bar import CinemaBar


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

Choose a reason for hiding this comment

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

The customer_instance should be created outside of the loop. The list comprehension is correct, but it should not be inside a loop. Move it outside the loop to create the list of Customer instances once.

cleaner_instance = Cleaner(cleaner)
hall = CinemaHall(hall_number)
Comment on lines +13 to +16

Choose a reason for hiding this comment

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

There is an unnecessary loop when creating instances of Customer, Cleaner, and CinemaHall. The loop should be removed, and the instances should be created outside of the loop. This will ensure that the instances are created only once, not repeatedly.

Comment on lines +13 to +16

Choose a reason for hiding this comment

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

The creation of customer_instance, cleaner_instance, and hall should be moved outside of the loop. Currently, these instances are being recreated in each iteration, which is inefficient and unnecessary.

for customer in customer_instance:
CinemaBar.sell_product(customer=customer, product=customer.food)
hall.movie_session(
movie_name=movie,
customers=customer_instance,
cleaner_staff=cleaner_instance)
Empty file added app/people/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions app/people/cinema_staff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from __future__ import annotations


class Cleaner:
def __init__(self, name: str) -> Cleaner:

Choose a reason for hiding this comment

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

The __init__ method should not have a return type annotation. Constructors in Python do not return a value, so the -> Cleaner annotation should be removed.

Choose a reason for hiding this comment

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

The __init__ method should not have a return type annotation or should be -> None, as it does not return any value.

self.name = name

def clean_hall(self, hall_number: int) -> Cleaner:

Choose a reason for hiding this comment

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

The clean_hall method should have a return type of None instead of Cleaner. Update the return type annotation to -> None.

Choose a reason for hiding this comment

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

The clean_hall method should not have a return type annotation or should be -> None, as it does not return any value.

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 @@
from __future__ import annotations


class Customer:

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

def watch_movie(self, movie: str) -> None:
print(f'{self.name} is watching "{movie}".')