Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Osoba:
- def __init__(self, name, last_name, age):
- self.name = name
- self.last_name = last_name
- self.age = age
- def get_name(self):
- return self.name
- def get_last_name(self):
- return self.last_name
- def get_age(self):
- return self.age
- class Note:
- def __init__(self, grades):
- self.grades = grades
- def get_grades(self):
- return self.grades
- def get_grade(self, subject):
- return self.grades.get(subject, None)
- class Student(Osoba):
- def __init__(self, name, last_name, age, index_nr, grades):
- super().__init__(name, last_name, age)
- self.index_nr = index_nr
- self.notes = Note(grades)
- def get_index_nr(self):
- return self.index_nr
- def get_notes(self):
- return self.notes.get_grades()
- class Group:
- def __init__(self):
- self.students = []
- def add_student(self, student):
- self.students.append(student)
- def get_students(self):
- return self.students
- def display_students(self):
- for student in self.students:
- print(f"Student: {student.get_name()} {student.get_last_name()}, Age: {student.get_age()}, Index: {student.get_index_nr()}")
- print(f"Grades: {student.get_notes()}")
- # Przykładowa inicjalizacja studentów
- grades_student1 = {
- "Mathematics": 5,
- "Physics": 4,
- "Chemistry": 3
- }
- grades_student2 = {
- "Mathematics": 4,
- "Physics": 5,
- "Chemistry": 4
- }
- student1 = Student("Anna", "Nowak", 22, "2021001", grades_student1)
- student2 = Student("Piotr", "Kowalski", 23, "2021002", grades_student2)
- # Przykładowa inicjalizacja grupy z dowolnymi studentami
- group = Group()
- group.add_student(student1)
- group.add_student(student2)
- # Wyświetlenie studentów w grupie
- group.display_students()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement