Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------abstraction--------------------------------
- // when we translit the object from real world to our class
- // we chose only the fatures witch e need in our class
- // for example create a class "Rectangle", and we need 4 variables for it description
- // they are coordinates of high left corner, width and height.
- class rect{
- float x,y,w,h;
- void draw(){}
- }
- // but such features as color and material are not important for my task
- //---------------------------polymorphism-------------------------------
- // the interface methods can be implemented in many ways
- // for example we have the interface "activity" and a method "doingActivities"
- interface activity{
- string doingActivities();
- }
- // it implements to the objects "workers"
- // as each worker can do different activities, each of them implement the method
- // "doingActivities" in different ways
- class BuildWorker implements activity{
- @overrite
- string doingActivities(){
- return "can Build";
- }
- }
- class CookWorker implements activity{
- @overrite
- string doingActivities(){
- return "can Cook";
- }
- }
- //---------------------------encapsulation-------------------------------
- // we need to hide some part of our code.
- class MyObject{
- private double mass;
- public double price;
- }
- // so that some variables and methods can not be changed;
- // for example we have object with mass as public parametr.
- class MyObject{
- public double mass;
- public double price;
- }
- // and someone has set it -12.
- // As the mass can not less then 0 the problems can appear
- //---------------------------inheritance--------------------------------------
- // this allows to use an existion code from another class
- // for example:
- class LampBulb {
- float power;
- void shine();
- }
- class LedLampBulb extends LampBulb{
- string [] someElectronics;
- }
- class FluorescentTubes extends LampBulb{
- string HighVoltageElectronics;
- }
- // extendsed classes LedLampBulb and FluorescentTubes also have variable "power"
- // and method "shine" from class LampBulb
- //---------------------------Delegation-------------------------------
- // is when cthe class transmit some part of it work to other classes
- // for instance the Boss has got some order and allocate it between workers
Add Comment
Please, Sign In to add comment