我目前正在制定学生课程计划。一切进展顺利,直到我发现自己难以理解谁允许我的初始化方法有一个参数days
哪些值可能是一周中的任何一天:mon, :tue, ...
更具体地说,我正在努力的是,我应该在哪里以及如何包含可以包含在class Course
这就是我的课程到目前为止的样子:
class Course
attr_reader :department, :name, :credits, :time_block, :days, :students
def initialize(course_name, department, credits, time_block = nil, days = nil) # where should I include the list of symbols : :mon,:tue,:weds ... ?? , also time_block?
@course_name = course_name
@department = department
@credits = credits
@students = []
@days = days
@time_block = time_block
end
def name
@course_name
end
def department
@department
end
def credits
@credits
end
def add_student(student)
return if @students.include?(student)
student.enroll(self)
end
def conflicts_with?(course2)
return false if self.time_block != course2.time_block
days.any? do |day|
course2.days.include?(day)
end
end
end
答案 0 :(得分:1)
PdfStamper
是的,就这么简单。