1620_lecture_12 - ITEC3620 Object-Based Programming Lecture...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
ITEC3620 Object-Based Programming Lecture 12 Methods, APIs, and Object Diagrams
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Methods Methods are functions that allow interaction with the data in an object Getting object information int input = userInput.nextInt(); double x = point.getX(); Some methods allow setting object information
Background image of page 2
Methods II Methods are like mathematical functions What happens with a = f (x, y)? largest = max(x, y);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Pieces of a Mathematical Function name max parameters x, y output/result larger value
Background image of page 4
Functions to Methods name identifier parameters parameters (with datatypes) output/result return value
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Signature for a Method <access modifiers> <return datatype> <identifier> ( <parameters> )
Background image of page 6
Example In the Math package static int max ( int x, int y ) Returns the greater of two int values
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example II int largest = Math.max (3, 5); largest 5
Background image of page 8
Methods in Action int largest = max (3, 5); Declare identifier largest, reserve space largest
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Methods in Action II Find method max with parameters (int, int) Copy parameters into method largest 3 5 x y max ()
Background image of page 10
Methods in Action III Execute method Return value back to calling statement (if return type is not void) largest 5
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Questions?
Background image of page 12
Overview What is object-based programming? Programming with objects
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/06/2010 for the course INFORMATIO ITEC 1620 taught by Professor Stephenchen during the Winter '10 term at York University.

Page1 / 38

1620_lecture_12 - ITEC3620 Object-Based Programming Lecture...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online