Postingan

OOP: 1 Understand the Difference Between Procedural and Object-Oriented Programming

One of the four basic principles of object-oriented programming (OOP) is  encapsulation .  Encapsulation  is a mechanism of hiding data implementation by restricting access to public methods. This topic was my first task in the OOP lesson. For example, this is the procedural version that I wrote in C. #include <stdio.h> #define PI 3.14159265359 int main(){           double r;           scanf("%lf\n", &r);           /*For example, I can add to the main           r = 3.0;           to directly reference variable r.  *\           printf("Radius: %.2f\n", r);           printf("Circumference: %.2f\n", 2 * PI * r);           printf("Area: %.2f\n", PI * r * r);           return 0;...