Created
September 13, 2018 22:19
-
-
Save pknowledge/f5d3aff5468eb3846eea2752f525b4df to your computer and use it in GitHub Desktop.
rectangle_Encapsulation.py
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
class Rectangle: | |
def __init__(self, height, width): | |
self.__height = height | |
self.__width = width | |
def set_height(self, height): | |
self.__height = height | |
def get_height(self): | |
return self.__height | |
def set_width(self, width): | |
self.__width = width | |
def get_width(self): | |
return self.__width | |
def area(self): | |
return self.__height * self.__width | |
rect1 = Rectangle(20, 60) | |
rect2 = Rectangle(50, 40) | |
print(rect1.area()) | |
print(rect2.area()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment