OOP Workshop
Button class
class Button:
buttonShape = "Line"
buttonColor = "Orange"
buttonX = 0
buttonY = 0
width = 100
height = 50
Button
is a new data type which contains some properties and methods specific to itself and its descendants.
Object oriented programming aims to provide the following major properties
Object oriented programming is built mainly upon the following concepts:
Abstraction: Packaging the methods in different classes, hiding away the implementation details from other parts of the code that only make use of that functionality, instead of implementing them.
Encapsulation: Packaging the fields or attributes that are internal to a class implementation and not exposing them unless necessary to other parts of the code.
Inheritance: Generating new classes by extending the functionality and properties of other classes, inheriting the existing properties and functionality of the extended class.
Polymorphism: Providing the ability to implement a given functionality of a class in a different way at any one of the inheriting classes. The program does not have to know about the exact type of the inheriting class and a simple call to the methods of those classes will respond with respect to their way of implementing the method.
You can find more formal definitions of these concepts online, and may be with different approaches based on the programming language.