Skip to content

Commit

Permalink
默认用户设置为Lyon,0001,主程序实现简单记录每日信息
Browse files Browse the repository at this point in the history
  • Loading branch information
WuLyon committed Dec 3, 2024
1 parent c920475 commit 863f569
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
14 changes: 8 additions & 6 deletions DearDiary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
import logging
import datetime
from user import User
import config

Expand All @@ -14,23 +14,25 @@ class DearDiary:

def __init__(self):
# 初始化一个默认用户
self.user = User(id=config.USER_ID, name=config.USER_NAME)
# self.user = User()
self.user = User('0001', 'Lyon')

def run(self):
'''
程序运行的主循环
'''
self.welcome()
is_done = input('Have you do something today? (y/n)')
if is_done.lower() == 'y':
self.user.add_op()
print(self.user)

def welcome(self):
'''
程序启动时的问候语
'''
print("Welcome to DearDiary, today is a nice day!")
print('----------------------------')
print(f"User: {self.user.name}")
print('----------------------------')
print(self.user)
print(f'{datetime.date.today()}')

def main():
deardiary = DearDiary()
Expand Down
7 changes: 6 additions & 1 deletion op_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def __init__(self, day=datetime.date.today(), subjects=None):
self.day = day
self.subjects = subjects if subjects is not None else []
if not self.subjects:
self.default_subjects()
# self.default_subjects()
self.Lyon_subjects()

self.day_point = self.calculate_day_point()

Expand All @@ -43,6 +44,10 @@ def default_subjects(self):

for subject in config.DEFAULT_SUBJECT:
self.add_subject(subject)

def Lyon_subjects(self):
for subject in config.LYON_SUBJECT:
self.add_subject(subject)


def to_dict(self):
Expand Down
2 changes: 1 addition & 1 deletion user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class User:

def __init__(self, id, name):
def __init__(self, id=config.USER_ID, name=config.USER_NAME):
self.id = id
self.name = name
self.score = 0
Expand Down

0 comments on commit 863f569

Please sign in to comment.