Advertisement
adolphuZ

Untitled

Jun 5th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. class Osoba:
  2.     def __init__(self, name, last_name, age):
  3.         self.name = name
  4.         self.last_name = last_name
  5.         self.age = age
  6.  
  7.     def get_name(self):
  8.         return self.name
  9.  
  10.     def get_last_name(self):
  11.         return self.last_name
  12.  
  13.     def get_age(self):
  14.         return self.age
  15.  
  16. class Note:
  17.     def __init__(self, grades):
  18.         self.grades = grades
  19.  
  20.     def get_grades(self):
  21.         return self.grades
  22.  
  23.     def get_grade(self, subject):
  24.         return self.grades.get(subject, None)
  25.  
  26. class Student(Osoba):
  27.     def __init__(self, name, last_name, age, index_nr, grades):
  28.         super().__init__(name, last_name, age)
  29.         self.index_nr = index_nr
  30.         self.notes = Note(grades)
  31.  
  32.     def get_index_nr(self):
  33.         return self.index_nr
  34.  
  35.     def get_notes(self):
  36.         return self.notes.get_grades()
  37.  
  38. class Employee(Osoba):
  39.     def __init__(self, name, last_name, age, salary, position):
  40.         super().__init__(name, last_name, age)
  41.         self.salary = salary
  42.         self.position = position
  43.  
  44.     def get_salary(self):
  45.         return self.salary
  46.  
  47.     def get_position(self):
  48.         return self.position
  49.  
  50. class WorkingStudent(Student, Employee):
  51.     def __init__(self, name, last_name, age, index_nr, grades, salary, position):
  52.         Student.__init__(self, name, last_name, age, index_nr, grades)
  53.         Employee.__init__(self, name, last_name, age, salary, position)
  54.  
  55. # Przykładowa inicjalizacja obiektu klasy WorkingStudent
  56. grades = {
  57.     "Mathematics": 4,
  58.     "Physics": 5,
  59.     "Chemistry": 3
  60. }
  61.  
  62. working_student = WorkingStudent("Anna", "Kowalska", 24, "2021001", grades, 2500, "Intern")
  63.  
  64. # Wyświetlenie danych pracującego studenta
  65. print(f"Working Student: {working_student.get_name()} {working_student.get_last_name()}, Age: {working_student.get_age()}")
  66. print(f"Index: {working_student.get_index_nr()}, Grades: {working_student.get_notes()}")
  67. print(f"Position: {working_student.get_position()}, Salary: {working_student.get_salary()} PLN")
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement