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 Employee(Osoba):
- def __init__(self, name, last_name, age, salary, position):
- super().__init__(name, last_name, age)
- self.salary = salary
- self.position = position
- def get_salary(self):
- return self.salary
- def get_position(self):
- return self.position
- class WorkingStudent(Student, Employee):
- def __init__(self, name, last_name, age, index_nr, grades, salary, position):
- Student.__init__(self, name, last_name, age, index_nr, grades)
- Employee.__init__(self, name, last_name, age, salary, position)
- # Przykładowa inicjalizacja obiektu klasy WorkingStudent
- grades = {
- "Mathematics": 4,
- "Physics": 5,
- "Chemistry": 3
- }
- working_student = WorkingStudent("Anna", "Kowalska", 24, "2021001", grades, 2500, "Intern")
- # Wyświetlenie danych pracującego studenta
- print(f"Working Student: {working_student.get_name()} {working_student.get_last_name()}, Age: {working_student.get_age()}")
- print(f"Index: {working_student.get_index_nr()}, Grades: {working_student.get_notes()}")
- print(f"Position: {working_student.get_position()}, Salary: {working_student.get_salary()} PLN")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement