1 / 22

ICM class 4

ICM class 4. Functions and Objects. Functions. Modularity. Functions. Modularity Reusability. Functions. Functions. ReturnType functionName (arguments){ } OutputType functionName (Input){ return output; }. Functions. int square(int number){ return number * number; }. Functions.

vera-bray
Télécharger la présentation

ICM class 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ICM class 4 Functions and Objects

  2. Functions • Modularity

  3. Functions • Modularity • Reusability

  4. Functions

  5. Functions ReturnType functionName (arguments){ } OutputType functionName (Input){ return output; }

  6. Functions int square(int number){ return number * number; }

  7. Functions Setup and draw… void

  8. Objects – Part 1 • Encapsulation • Modularity

  9. Encapsulation • An object is a bundle of variables, statements and functions

  10. Encapsulation

  11. Encapsulation class Car{ //declare properties Car(){ //init properties } //declare more methods }

  12. Encapsulation Car car1; void setup(){ car1 = new Car(); } void draw(){ car1.doSomething(); }

  13. Encapsulation • Lets try it together

  14. Encapsulation Makes it easy to have more than 1

  15. Encapsulation • Conceals the functional details

  16. Modularity • Independent components

  17. Objects – Part 2 • Inheritance • Overloading

  18. Inheritance • Animals, cats and dogs… and elephants and giraffes, and goldfish!

  19. Inheritance class Animal{ Animal(){} } class Cat extends Animal { Cat(){ super(); } }

  20. Overloading • Same function name + different arguments • Ie. fill(255); • fill(255,123,0); • fill(255,123,0,115);

  21. Why OOP • Easier updating • Easier debugging • Easier sharing • Reusable maintainable code

  22. Why OOP • You don’t want to be like this guy

More Related