change file save path
This commit is contained in:
27
courses/Course.py
Normal file
27
courses/Course.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from courses.Attachment import Attachment
|
||||
|
||||
|
||||
class Course:
|
||||
def __init__(self, course_id, title, attachments=None):
|
||||
self.id = course_id
|
||||
self.title = title
|
||||
self.attachments = attachments if attachments else []
|
||||
|
||||
def add_attachment(self, attachment):
|
||||
self.attachments.append(attachment)
|
||||
|
||||
def __repr__(self):
|
||||
return f"Course(id={self.id}, title={self.title}, attachments={self.attachments})"
|
||||
|
||||
|
||||
# 使用示例
|
||||
# 创建附件实例
|
||||
attachment1 = Attachment(attachment_id=1, course_id=101, name='Lesson 1', url='http://example.com/lesson1.mp3')
|
||||
attachment2 = Attachment(attachment_id=2, course_id=101, name='Lesson 2', url='http://example.com/lesson2.mp3')
|
||||
|
||||
# 创建课程实例,并添加附件
|
||||
course = Course(course_id=101, title='Introduction to Python')
|
||||
course.add_attachment(attachment1)
|
||||
course.add_attachment(attachment2)
|
||||
|
||||
print(course)
|
||||
Reference in New Issue
Block a user