Created
May 28, 2015 07:33
-
-
Save rm77/137c4609d4a485c264e4 to your computer and use it in GitHub Desktop.
model for virtual knowledge market
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Author: | |
def __init__(self,author_id,author_name): | |
self.author_id = author_id | |
self.author_name = author_name | |
def get_id(self): | |
return self.author_id | |
def get_author_name(self): | |
return self.author_name | |
class Teacher: | |
def __init__(self,teacher_id,teacher_name): | |
self.teacher_id = teacher_id | |
self.teacher_name = teacher_name | |
def get_id(self): | |
return self.teacher_id | |
def get_teacher_name(self): | |
return self.teacher_name | |
class Student: | |
def __init__(self,student_id,student_name): | |
self.student_id = student_id | |
self.student_name = student_name | |
def get_id(self): | |
return self.student_id | |
def get_student_name(self): | |
return self.student_name | |
def subscribe(self,school_class_instance): | |
school_class_instance.add_student(self) | |
class Course: | |
def __init__(self,course_id,course_title,course_price): | |
self.course_id = course_id | |
self.course_title = course_title | |
self.course_price = course_price | |
self.reputation = 0 | |
self.course_authors = [] | |
self.school = '' | |
def get_id(self): | |
return self.course_id | |
def add_author(self,author_instance): | |
self.course_authors.append(author_instance) | |
def get_authors(self): | |
return self.course_authors | |
def get_course_title(self): | |
return self.course_title | |
def set_course_title(self,course_title): | |
self.course_title = course_title | |
def set_price(self,price): | |
self.course_price = price | |
def get_price(self): | |
return self.course_price | |
def set_reputation(self,rep): | |
self.reputation = rep | |
def get_reputation(self): | |
return self.reputation | |
class SchoolClass: | |
def __init__(self,class_id,course_instance): | |
self.class_id = class_id | |
self.course = course_instance | |
self.students = {} | |
self.teachers = {} | |
self.marks = {} | |
def get_class_id(self): | |
return self.class_id | |
def add_teacher(self,teacher_instance): | |
self.teachers[teacher_instance.get_id()]=teacher_instance | |
def add_student(self,student_instance): | |
self.students[student_instance.get_id()]=student_instance | |
def get_students(self): | |
return self.students | |
def get_teachers(self): | |
return self.teachers | |
def get_student_by_id(self,student_id): | |
return self.students[student_id] | |
def get_teacher_by_id(self,teacher_id): | |
return self.teachers[teacher_id] | |
def get_instance(self): | |
return self | |
def set_student_mark(self,student_id,mark): | |
self.marks[student_id]=mark | |
def get_student_mark(self,student_id): | |
return self.marks[student_id] | |
def get_class_result(self): | |
y=[] | |
for x in self.students: | |
y.append((x,self.marks[x])) | |
return y | |
class School: | |
def __init__(self,school_id,school_name): | |
self.school_id = school_id | |
self.school_name = school_name | |
self.school_class = {} | |
self.reputation = 0 | |
def get_id(self): | |
return self.school_id | |
def get_school_name(self): | |
return self.school_name | |
def add_class(self,school_class_instance): | |
self.school_class[school_class_instance.get_class_id()]=school_class_instance | |
def set_reputation(self,rep): | |
self.reputation = rep | |
def get_reputation(self): | |
return self.reputation | |
if __name__=='__main__': | |
author1 = Author('A1','Mr. Jones') | |
author2 = Author('A2','Royyana') | |
student1 = Student('SA1','Arnold Muhren') | |
student2 = Student('SA2','Vanenburg') | |
student3 = Student('SA3','Wouters') | |
teacher1 = Teacher('TA1','Mark Jones') | |
teacher2 = Teacher('TA2','Mark Wright') | |
course1 = Course('C1','science',course_price=250) | |
s1class1 = SchoolClass('S1C101',course1) | |
s1class1.add_teacher(teacher1) | |
s1class1.add_teacher(teacher2) | |
s1class1.add_student(student1) | |
s1class1.add_student(student2) | |
student3.subscribe(s1class1) | |
s1 = School('S1','University of Mojopahit') | |
s1.add_class(s1class1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment