2 つの異なる教室に異なるコースを追加したいのですが、両方の教室に同じコースが追加され続けます。これは私の AddCourse 関数です
編集済み
あなたの提案に従ってコードを修正しました。
class Classroom:
"""I omitted part of the class for brevity"""
def __init__(self, Seed = None, ClassroomId = None, FirstCourseStartTime = None, LastCourseEndTime = None, CourseList = [], ProfessorList = []):
self.setFirstCourseStartTime(FirstCourseStartTime)
self.setLastCourseEndTime(LastCourseEndTime)
self.setCourseList(CourseList)
self.setProfessorList(ProfessorList)
self.setSeed(Seed)
self.setClassroomId(ClassroomId)
def addCourse(self, Course):
self.CourseList.append(Course)
def setCourseList(self, List):
self.CourseList = List
#the statements below are from a different file to run the code/class above
Classroom1 = Classroom(Seed = os.urandom(1024/8), FirstCourseStartTime = 8, LastCourseEndTime = 19.75)
Classroom2 = Classroom(Seed = os.urandom(1024/8), FirstCourseStartTime = 8, LastCourseEndTime = 19.75)
# Adding the courses to the classrooms
Classroom1.addCourse(Course0)
Classroom1.addCourse(Course1)
Classroom1.addCourse(Course2)
Classroom1.addCourse(Course3)
Classroom1.addCourse(Course4)
Classroom1.addCourse(Course5)
Classroom1.addCourse(Course6)
Classroom1.addCourse(Course7)
Classroom2.addCourse(Course8)
Classroom2.addCourse(Course9)
Classroom2.addCourse(Course10)
Classroom2.addCourse(Course11)
Classroom2.addCourse(Course12)
Classroom2.addCourse(Course13)
Classroom2.addCourse(Course14)
Classroom2.addCourse(Course15)