-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6c0972
commit 68dd187
Showing
4 changed files
with
204 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
class Student: | ||
obj_count = 0 | ||
stud_list = dict() | ||
|
||
def __init__(self, rn = 0, st_name = 'Name', *clubs): # Parametric Constructor | ||
Student.obj_count += 1 | ||
self.roll_no = rn | ||
self.name = st_name | ||
self.club = clubs | ||
Student.stud_list[rn] = st_name | ||
|
||
def study(self): | ||
print(f'{self.name} is Studying....') | ||
def wake(self): | ||
self.study() | ||
return 'Woke' | ||
|
||
def __del__(self): # destructor | ||
Student.obj_count -= 1 | ||
Student.stud_list.pop(self.roll_no) | ||
|
||
def __repr__(self): | ||
return f'Roll no.: {self.roll_no} \nName: {self.name}\n'\ | ||
f'Clubs: {self.club}' | ||
|
||
def __lt__(self, obj): | ||
return self.name < obj.name | ||
def __le__(self, obj): | ||
return self.name <= obj.name | ||
def __gt__(self, obj): | ||
return self.name > obj.name | ||
def __ge__(self, obj): | ||
return self.name >= obj.name | ||
def __ne__(self, obj): | ||
return self.name != obj.name | ||
def __eq__(self, obj): | ||
return self.name == obj.name | ||
|
||
def __getitem__(self, key): | ||
return self.club[key-1] | ||
def __setitem__(self, key, value): | ||
self.club[key-1] = value | ||
|
||
# getter | ||
@property | ||
def roll_no(self): | ||
#print('Getter called') | ||
return self.__roll_no | ||
|
||
#setter | ||
@roll_no.setter | ||
def roll_no(self, rn): | ||
#print('Setter called') | ||
self.__roll_no = rn | ||
|
||
|
||
|
||
|
||
# Object 1 | ||
st1 = Student(1, 'Prabhu', 'Coding Club', 'Robotics Club') | ||
print(st1.wake()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters