mirror of
https://github.com/robindhole/fundamentals.git
synced 2025-09-14 08:52:39 +00:00
Adds python code (#7)
This commit is contained in:

committed by
GitHub

parent
8c24d0345a
commit
59d2d5acfb
20
python_code/oop/inheritance/Student.py
Normal file
20
python_code/oop/inheritance/Student.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from oop.inheritance.User import *
|
||||
from oop.inheritance.StudentStatus import *
|
||||
|
||||
class Student(User):
|
||||
|
||||
__status = StudentStatus.ACTIVE
|
||||
|
||||
def __init__(self, name: str, email: str, batch_name: str, psp: int) -> None:
|
||||
super().__init__(name, email)
|
||||
self.__batch_name = batch_name
|
||||
|
||||
if (psp < 0 or psp > 100):
|
||||
raise Exception("PSP should be between 0 and 100")
|
||||
self.__psp = psp
|
||||
|
||||
def print_details(self) -> None:
|
||||
print("In Student", self.get_name(), self.__batch_name)
|
||||
|
||||
def change_batch(self, batch_name: str) -> None:
|
||||
self.batch_name = batch_name
|
6
python_code/oop/inheritance/StudentStatus.py
Normal file
6
python_code/oop/inheritance/StudentStatus.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from enum import Enum
|
||||
|
||||
class StudentStatus(Enum):
|
||||
ACTIVE = 1
|
||||
PAUSED = 1
|
||||
COMPLETED = 1
|
16
python_code/oop/inheritance/User.py
Normal file
16
python_code/oop/inheritance/User.py
Normal file
@@ -0,0 +1,16 @@
|
||||
class User:
|
||||
def __init__(self, name: str, email: str) -> None:
|
||||
self.__name = name
|
||||
self.__email = email
|
||||
|
||||
def change_email(self, email: str) -> None:
|
||||
self.__email = email
|
||||
|
||||
def get_name(self) -> str:
|
||||
return self.__name
|
||||
|
||||
def print_details(self) -> None:
|
||||
print("Print with no args")
|
||||
|
||||
def print_details(self, title: str) -> None:
|
||||
print("\n In User:", title, self.get_name())
|
Reference in New Issue
Block a user