Folder 클래스
Amazon Q Developer로 쉽게 클래스를 만들수 있습니다. Amanon Q Developer에 다음 프롬프트를 사용하여 클래스를 생성하도록 요청합니다.
예시 #1
Folder 클래스 생성
일반적인 프롬프트
create a class called "Folders"
folders has name, children, and optional parent
a child cannot be added twice
Python 프롬프트
VSCode에서 파일을 생성하고 이름을 folder_class.py
로 지정하고 다음 코드를 입력합니다.
"""
create a class called "Folders"
folders has name, children, and optional parent
a child cannot be added twice
"""
제안을 수락하려면 Enter 키를 계속 누릅니다. Amazon Q Developer가 다음 코드를 생성합니다.
예시 #2
Folder 클래스 계속해서 생성
Enter 키를 계속 누르면 Amazon Q Developer가 계속해서 클래스를 추가/생성합니다.
일반적인 프롬프트
엔터만 입력할 것이기 때문에 추가로 입력할 내용이 없습니다.
Python 프롬프트
코드 제안의 끝으로 가서 Enter 키를 누릅니다. 그러면 Amazon Q Developer가 클래스에 다음 코드를 추가할 것입니다.
--> We are hitting enter. No need to type anything. Just hit enter.
현재 코드:
def __eq__(self, other) -> bool:
return self.name == other.name
def __hash__(self) -> int:
return hash(self.name)
def get_path(self) -> List[str]:
if self.parent is None:
return [self.name]
return [self.name] + self.parent.get_path()
Last updated