-
Notifications
You must be signed in to change notification settings - Fork 0
feature/define cafe order system #12
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
8a06af1
faf3d9b
eb71be2
170f291
91004ff
458949d
a962395
22a02cb
1a2eadd
df79f7c
c3006ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,97 @@ | ||||||
| """ | ||||||
| 각종 음료 관련 코드 | ||||||
|
|
||||||
| Description: | ||||||
| 추상클래스 Beverage를 상속받아, Espresso, HouseBlend 구현 | ||||||
|
|
||||||
| Author: | ||||||
| Name: Gangmin Kim | ||||||
| Email: rlarkdals7@gmail.com | ||||||
| """ | ||||||
| from abc import ABCMeta, abstractmethod | ||||||
|
|
||||||
|
|
||||||
| class Beverage(metaclass=ABCMeta): | ||||||
| """summary | ||||||
| Description: | ||||||
| 다양한 Beverage들을 구현하기 위한 Abstractive class | ||||||
| """ | ||||||
|
|
||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
| def getdescription(self) -> str: | ||||||
|
||||||
| def getdescription(self) -> str: | |
| def get_description(self) -> str: |
으로 끊어주면 어떨까요?
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.
넵 피드백 감사합니다
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.
input이나 return이 없는 경우, 작성하지 않는 것을 표준으로 하겠습니다!
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.
넵 확인했습니다 다음 커밋 시 반영하겠습니다.
Outdated
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.
summary 단어 제거 부탁합니다!
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.
넵 알겠습니다!
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| """ | ||
| 각종 음료 관련 코드 | ||
|
|
||
| Description: | ||
| 추상클래스 Beverage를 상속받아, Espresso, HouseBlend 구현 | ||
|
|
||
| Author: | ||
| Name: Gangmin Kim | ||
| Email: rlarkdals7@gmail.com | ||
| """ | ||
| from typing import Any | ||
|
|
||
| from beverage import Beverage | ||
|
|
||
|
|
||
| class CondimentDecorator(Beverage): | ||
| """summary | ||
| Description: | ||
| 첨가물을 나타내는 추상클래스 | ||
| """ | ||
|
|
||
| def __init__(self, bevarage: Beverage) -> None: | ||
| """상속받는 클래스에 따라 구현 | ||
|
|
||
| Args: | ||
| None | ||
|
|
||
| Returns: | ||
| None | ||
| """ | ||
| super().__init__() | ||
| self._beverage = bevarage | ||
|
|
||
| @property | ||
| def beverage(self) -> Beverage: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추상클래스에서
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 검색 키워드 : |
||
| """summary | ||
| Description: | ||
| 상속받는 클래스에 따라 구현 | ||
|
|
||
| Args: | ||
| None | ||
|
|
||
| Returns: | ||
| None | ||
| """ | ||
| return self._beverage | ||
|
|
||
| def getdescription(self) -> Any: | ||
| """summary | ||
| Description: | ||
| 상속받는 클래스에 따라 Beverage의 이름 출력 구현 | ||
|
|
||
| Args: | ||
| None | ||
|
|
||
| Returns: | ||
| None | ||
| """ | ||
| return self._beverage.getdescription() | ||
|
|
||
| def cost(self) -> Any: | ||
| """summary | ||
| Description: | ||
| 상속받는 클래스에 따라 Beverage의 가격 출력 구현 | ||
|
|
||
| Args: | ||
| None | ||
|
Comment on lines
+62
to
+63
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이부분 제거되어도 좋을듯합니다! |
||
|
|
||
| Returns: | ||
| None | ||
| """ | ||
| return self._beverage.cost() | ||
|
|
||
|
|
||
| class Mocha(CondimentDecorator): | ||
| """summary | ||
| Description: | ||
| Mocha를 나타내는 클래스 | ||
| """ | ||
|
|
||
| def getdescription(self) -> Any: | ||
| """summary | ||
| Description: | ||
| 설명을 덧붙이는 함수 | ||
| """ | ||
| return self.beverage.getdescription() + ", 모카" | ||
|
|
||
| def cost(self) -> Any: | ||
| """summary | ||
| Description: | ||
| cost 계산시 0.2를 더해준다. | ||
| """ | ||
| return self.beverage.cost() + 0.20 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| """ | ||
| cafe order test 코드 | ||
|
|
||
| Description: | ||
| cafe order 테스트를 위한 코드 | ||
|
|
||
| Author: | ||
| Name: Gangmin Kim | ||
| Email: rlarkdals7@gmail.com | ||
| """ | ||
|
|
||
| from beverage import Espresso, HouseBlend | ||
| from condiment import Mocha | ||
|
|
||
|
|
||
| def main() -> None: | ||
| """summary | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제거! |
||
| Description: | ||
| Test 진행함수 | ||
| Args : | ||
| None | ||
| Returns : | ||
| None | ||
| """ | ||
| bevarage = Espresso() | ||
| print(bevarage.getdescription() + " $" + str(bevarage.cost())) | ||
|
|
||
| beverage2 = HouseBlend() | ||
| beverage2 = Mocha(beverage2) | ||
| print(beverage2.getdescription() + " $" + str(beverage2.cost())) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
https://docs.python.org/ko/3/library/abc.html
:
abstractmethod이 데코레이터를 사용하려면 클래스의 메타 클래스가 [ABCMeta]이거나 여기에서 파생된 것이어야 합니다.라고 공식문서에 적혀있습니다.