오늘 하루는 14시 까지 팀과제 마무리를 못한것을 마무리했다.
import hashlib # 해쉬 불러오기
#Member Class
class Member():
def __init__(self, name, username, password):
self.name = name
self.username = username
self.password = self.hash_password(password)
# 게시물 출력
def display(self):
print(f"이름: {self.name}, 아이디: {self.username}")
@staticmethod
def hash_password(password):
return hashlib.sha256(password.encode()).hexdigest()
# Post class
class Post():
def __init__(self, username, title, content):
self.author = username # 인스턴스 변수 author
self.title = title # 인스턴스 변수 title
self.content = content # 인스턴스 변수 content
# 게시물 출력
def display(self):
print(f"작성자: {self.author}, 제목: {self.title}, 내용 : {self.content}")
#member 생성함수
def create_member():
name = input("이름을 입력하세요: ")
username = input("아이디를 입력하세요: ")
password = input("비밀번호를 입력하세요: ")
return Member(name, username, password)
# post 생성 함수
def create_post(username):
title_name = input("제목을 작성해주세요:")
content_detail = input("내용을 작성해주세요:")
return Post(username, title_name, content_detail)
# member instance
member1 = Member("승원", "one1122", "qw1122")
member2 = Member("원빈", "beanone", "bboo1122")
member3 = Member("지민", "ming22", "password98")
member4 = Member("리나", "rina0000", "qwerty@")
# member list
# member 를 추가하면 여기에 리스트에 append
members = []
# member add
members.append(member1)
members.append(member2)
members.append(member3)
members.append(member4)
# 맴버 추가 반복문
while True:
question = input("새 회원을 등록하시겠습니까? (y/n): ").lower()
if question.lower() != 'y':
break
member = create_member()
members.append(member)
print(f"{member.name} 회원이 등록되었습니다.")
print("\n회원 목록:") # 추가한 회원 및 원래 있던 회원들 출력
for member in members:
member.display()
# post list
posts = []
# post 추가 반복문
while True:
question = input("새 게시물을 등록하시겠습니까? (y/n): ").lower() # y를 누르면 아이디 입력으로 이동 n 이면 게시물 작성 취소
if question == 'y':
username = input("아이디 입력하세요").lower()
if any(member.username == username for member in members): # any() : 하나라도 True인게 있으면 True / username이 회원들 중 한명과 username 이 같으면 new post 변수생성
new_post = create_post(username)
# 작성자, 제목, 내용을 다 입력한 경우 출력됨
print('글을 작성하셨습니다.')
print(f"작성자: {new_post.author}") # 새 post 작성자
print(f"제목: {new_post.title}") # 새 post 제목
print(f"내용: {new_post.content}") # 새 post 내용
posts.append(new_post) # new post를 posts에 리스트 추가
# 새로 만든 posts 중 각 게시물이 3개 이상이면 break, 3개 미만이면 continue
for post in posts:
if 3 <= len(posts):
print("게시물이 3개 이상입니다")
break
else:
print("게시물이 3개보다 적습니다")
continue
else: # 아이디를 입력을 제대로 못하면 나타나는 print
print("제대로 입력되지 않았습니다")
continue
else: # 게시물 작성 취소
print("게시물 작성을 취소하였습니다.")
break
# post 목록들 출력
print("\n게시물 목록:")
for post in posts:
post.display()
while True:
k = input("유저 아이디를 검색하려면 a/ 특정단어를 검색하고 싶으면b") # a 입력하면 특정유저가 작성한 게시글의 제목할 수 있는 페이지로 이동
# b 입력하면 ‘특정 단어’가 내용에 포함된 게시글의 제목 출력
if k == 'a': # 특정 유저 조회
user_post = input("조회할 유저의 아이디를 검색하세요")
for post in posts:
if user_post == post.author: # 내가 입력한 유저의 아이디가 post에 있는 author과 일치하면 제목출력
print(post.title)
break
else:
print("아이디와 같은 아이디가 없습니다")
break
# 특정 단어 조회
elif k == 'b':
user_keyword = input("특정단어를 검색하세요")
for post in posts:
if user_keyword in post.content: # 내가 입력한 단어가 post의 content 안에 있을경우 제목출력
print(post.title)
break
else:
print("입력한 단어와 관련된 내용이 없습니다.")
break
팀회의 끝에 각자 한번 스스로 3번과제를 마무리 하기로 결정했다.
any() = 하나라도 True인게 있으면 True /
if user_keyword in post.content
항상 if 문을 사용했을때는 ==, <= 등 연산자를 많이 사용했지만 in 을 쓴건 처음이기에 기억에 남아서 적어봤다.
import hashlib
해쉬 패스워드를 불러올때 import를 불러왔다.
그리고 팀원들과 회의 끝에
while True:
k = input("유저 아이디를 검색하려면 a/ 특정단어를 검색하고 싶으면b") # a 입력하면 특정유저가 작성한 게시글의 제목할 수 있는 페이지로 이동
# b 입력하면 ‘특정 단어’가 내용에 포함된 게시글의 제목 출력
if k == 'a': # 특정 유저 조회
user_post = input("조회할 유저의 아이디를 검색하세요")
for post in posts:
if user_post == post.author: # 내가 입력한 유저의 아이디가 post에 있는 author과 일치하면 제목출력
print(post.title)
break
else:
print("아이디와 같은 아이디가 없습니다")
break
# 특정 단어 조회
elif k == 'b':
user_keyword = input("특정단어를 검색하세요")
for post in posts:
if user_keyword in post.content: # 내가 입력한 단어가 post의 content 안에 있을경우 제목출력
print(post.title)
break
else:
print("입력한 단어와 관련된 내용이 없습니다.")
break
이 부분을 다른 팀원들이 각자 잘하는 것 부분을 합치기로 했다.
뿌듯하다.^^
저녁먹고 오후 팀 회의에서 튜터님께 협업을 어떻게 해야 효율적인지를 물어봤다.
1). 각자 구현후 코드 리뷰
- 피드백 할때
1. 비판적의견(정당한)
2. 그 비판적 의견에 대한 수용
3. 정답이 아니여도 적극적으로 제시
2). 차라리 아예 다같이 하기
- 한명이 화면공유 하고 다같이 의견 제시
3). 분담
- 바통 넘기듯이
- 시간 상대적으로 남는 인원들 다른것 공부하기
- html 틀 작성해놓기
이런 의견들이 나왔지만 우리는 분담을 하기로 결정을 하였다

4번 과제는 이렇게 구도를 만들었다.
다음주에도 멋진 팀 과제를 만들수 있다는 생각을 가지며 이번주 고생한 나에게도 고맙다고 말하고 싶다.