Icm class 4
This presentation is the property of its rightful owner.
Sponsored Links
1 / 22

ICM class 4 PowerPoint PPT Presentation


  • 70 Views
  • Uploaded on
  • Presentation posted in: General

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.

Download Presentation

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Icm class 4

ICM class 4

Functions and Objects


Functions

Functions

  • Modularity


Functions1

Functions

  • Modularity

  • Reusability


Functions2

Functions


Functions3

Functions

ReturnType functionName (arguments){

}

OutputType functionName (Input){

return output;

}


Functions4

Functions

int square(int number){

return number * number;

}


Functions5

Functions

Setup and draw… void


Objects part 1

Objects – Part 1

  • Encapsulation

  • Modularity


Encapsulation

Encapsulation

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


Encapsulation1

Encapsulation


Encapsulation2

Encapsulation

class Car{

//declare properties

Car(){

//init properties

}

//declare more methods

}


Encapsulation3

Encapsulation

Car car1;

void setup(){

car1 = new Car();

}

void draw(){

car1.doSomething();

}


Encapsulation4

Encapsulation

  • Lets try it together


Encapsulation5

Encapsulation

Makes it easy to have more than 1


Encapsulation6

Encapsulation

  • Conceals the functional details


Modularity

Modularity

  • Independent components


Objects part 2

Objects – Part 2

  • Inheritance

  • Overloading


Inheritance

Inheritance

  • Animals, cats and dogs… and elephants and giraffes, and goldfish!


Inheritance1

Inheritance

class Animal{

Animal(){}

}

class Cat extends Animal {

Cat(){

super();

}

}


Overloading

Overloading

  • Same function name + different arguments

  • Ie. fill(255);

  • fill(255,123,0);

  • fill(255,123,0,115);


Why oop

Why OOP

  • Easier updating

  • Easier debugging

  • Easier sharing

  • Reusable maintainable code


Why oop1

Why OOP

  • You don’t want to be like this guy


  • Login