Download
icm class 4 n.
Skip this Video
Loading SlideShow in 5 Seconds..
ICM class 4 PowerPoint Presentation
Download Presentation
ICM class 4

ICM class 4

97 Vues Download Presentation
Télécharger la présentation

ICM class 4

- - - - - - - - - - - - - - - - - - - - - - - - - - - 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