11"""
2- Lecture 3 - Setters & Getters
2+ Setters & Getters Example
33"""
44
55from machine import Pin
66from time import sleep , time
77
88
99class Led_Light (Pin ):
10- # child class inherits the parent 'Pin' class
10+ # Sub Class inherits the Super 'Pin'
1111 def __init__ (self , pin , flashing = False , debug = False ):
1212 super ().__init__ (pin , Pin .OUT )
1313 self .led_light_state
@@ -16,32 +16,32 @@ def __init__(self, pin, flashing=False, debug=False):
1616 self .__flashing = flashing
1717
1818 def on (self ):
19- # method overriding polymorphism of the parent class
19+ # method overriding polymorphism of the Super Class
2020 self .high ()
2121 if self .__debug :
2222 print (f"LED connected to Pin { self .__pin } is { self .led_light_state } " )
2323
2424 def off (self ):
25- # method overriding polymorphism of the parent class
25+ # method overriding polymorphism of the Super Class
2626 self .low ()
2727 if self .__debug :
2828 print (f"LED connected to Pin { self .__pin } is { self .led_light_state } " )
2929
3030 def toggle (self ):
31- # method overriding polymorphism of the parent class
31+ # method overriding polymorphism of the Super Class
3232 if self .value () == 0 :
3333 self .on ()
3434 elif self .value () == 1 :
3535 self .off ()
3636
3737 @property
3838 def led_light_state (self ):
39- # method overloading polymorphism in this class
39+ # method overloading polymorphism in this
4040 return self .value ()
4141
4242 @led_light_state .setter
4343 def led_light_state (self , value ):
44- # method overloading polymorphism in this class
44+ # method overloading polymorphism in this
4545 if value == 1 :
4646 self .off ()
4747 elif value == 0 :
0 commit comments