-
Notifications
You must be signed in to change notification settings - Fork 2
Create Pizzeria_oop #3
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
Open
Seniacat
wants to merge
3
commits into
smartiqaorg:main
Choose a base branch
from
Seniacat:pizza_review
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| class Pizza: | ||
|
|
||
| SMALL = 25 | ||
| MEDIUM = 30 | ||
| LARGE = 40 | ||
| PEPPERONI = "Pepperoni type" | ||
| MARGARITA = "Margarita type" | ||
| COOKING = 0 | ||
| READY = 1 | ||
|
|
||
| def __init__(self, ingredients, size): | ||
| self.ingredients = ingredients | ||
| self.size = size | ||
| self.ready = Pizza.COOKING | ||
|
|
||
| def cook(self): | ||
| print('Pizza is being cooked...') | ||
| self.ready = Pizza.READY | ||
| print('Pizza is ready!') | ||
|
|
||
|
|
||
| class Pepperoni(Pizza): | ||
|
|
||
| pepperoni_ings = ['Salami', 'Cheese'] | ||
|
|
||
| def __init__(self, size): | ||
| super().__init__(Pepperoni.pepperoni_ings, size) | ||
|
|
||
|
|
||
| class Margarita(Pizza): | ||
|
|
||
| margarita_ings = ['Tomato', 'Cheese'] | ||
|
|
||
| def __init__(self, size): | ||
| super().__init__(Margarita.margarita_ings, size) | ||
|
|
||
|
|
||
| class Worker: | ||
|
|
||
| def __init__(self): | ||
| self.order = None | ||
| self.__cash = 0 | ||
|
|
||
| @staticmethod | ||
| def greet_client(name): | ||
| print(f"Welcome, {name}!") | ||
|
|
||
| def get_order(self, pizza_type, pizza_size): | ||
| if pizza_type == Pizza.PEPPERONI: | ||
| self.order = Pepperoni(pizza_size) | ||
| elif pizza_type == Pizza.MARGARITA: | ||
| self. order = Margarita(pizza_size) | ||
|
|
||
| def get_money(self, money): | ||
| self.__cash += money | ||
|
|
||
| def process_order(self): | ||
| self.order.cook() | ||
| return self.order | ||
|
|
||
|
|
||
| class Client: | ||
| default_name = 'Alex' | ||
|
|
||
| def __init__(self, money, name=default_name): | ||
| self.__money = money | ||
| self.name = name | ||
| self.pizza = None | ||
|
|
||
| @staticmethod | ||
| def choose_margarita_pizza(): | ||
| return Pizza.MARGARITA | ||
|
|
||
| @staticmethod | ||
| def choose_pepperoni_pizza(): | ||
| return Pizza.PEPPERONI | ||
|
|
||
| @staticmethod | ||
| def choose_small_size(): | ||
| return Pizza.SMALL | ||
|
|
||
| @staticmethod | ||
| def choose_medium_size(): | ||
| return Pizza.MEDIUM | ||
|
|
||
| @staticmethod | ||
| def choose_large_size(): | ||
| return Pizza.LARGE | ||
|
|
||
| def pay_money(self, money): | ||
| self.__money -= money | ||
|
|
||
| def get_pizza(self, pizza): | ||
| self.pizza = pizza | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В целом по программе: необходимо разобраться в пустыми строками. Как правильно, Style Guide для Python находится в официальном документе PEP8 - в нем подробно описано, как нужно писать читабельный код: https://www.python.org/dev/peps/pep-0008
Так вот касательно пустых строк в нем написано так:
То есть классы отделяются друг от друга двумя пустыми строками, функции - одной, внутри самих функций тоже возможны пустые строки, если нужно выделить какие-то логические части.
Руководствуясь этими принципами, поправьте пустые строки в вашей программе.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Честно говоря,стараюсь не писать вот так в одну строку функции. Но тут показалось,что вышла портянка,хотела уменьшить визуально ее,но получилось только хуже. Исправляюсь)