diff options
author | Zhongheng Liu <z.liu@outlook.com.gr> | 2025-02-19 09:43:52 +0200 |
---|---|---|
committer | Zhongheng Liu <z.liu@outlook.com.gr> | 2025-02-19 09:43:52 +0200 |
commit | 8834da60a01294fd509c7cebf3b129fcc378d152 (patch) | |
tree | a1c6c4bd71e95780f87d35240754c5b54d3042ae /_legacy/py-class.py | |
parent | 34bd7099d27656b4454015b0c410ca1713db5271 (diff) | |
download | cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.tar.gz cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.tar.bz2 cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.zip |
chore: changing to ipynb
Diffstat (limited to '_legacy/py-class.py')
-rw-r--r-- | _legacy/py-class.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/_legacy/py-class.py b/_legacy/py-class.py new file mode 100644 index 0000000..c4eec79 --- /dev/null +++ b/_legacy/py-class.py @@ -0,0 +1,31 @@ +class Student: + def __init__(self, name: str, dateOfBirth: str, examMark: int): + self.__name = name + self.__dateOfBirth = dateOfBirth + self.__examMark = examMark + def displayExamMark(self): + print(f"{self.__name} got {self.__examMark} marks") + + +class PartTimeStudent(Student): + def __init__(self, name: str, dateOfBirth: str, examMark: int): + self.__isFullTime = False + super().__init__(name, dateOfBirth, examMark) + def time(self): + return "Full time" if self.__isFullTime else "Part time" + + +class FullTimeStudent(Student): + def __init__(self, name: str, dateOfBirth: str, examMark: int): + self.__isFullTime = True + super().__init__(name, dateOfBirth, examMark) + def time(self): + return "Full time" if self.__isFullTime else "Part time" + + +myStudent = Student("Example Exampleperson", "1989-06-04", 69) +myStudent.displayExamMark() +myFullStudent = FullTimeStudent("Dwayne Johnson", "1999-9-9", 80) +myPartStudent = PartTimeStudent("Jake Paul", "1999-9-9", 0) +myPartStudent.displayExamMark() +myFullStudent.displayExamMark() |