06-07feb08methods - C S100J 8 F ebruary 2 005 M eth o d b o...

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

View Full Document Right Arrow Icon
1 1 CS100J 8 February 2005 Discussion of Methods: Functions, procedures, constructors. The return statement in a function. Executing method calls. For this and next lecture: Read section 2.3 but NOT 2.3.8!!!! Do the self-review exercises in 2.3.4 Oxymoron: a combination for epigrammatic effect of contradictory or incongruous words (as cruel kindness, laborious idleness ) airline food State worker military intelligence peace force Microsoft Works computer security sanitary landfill tight slacks religious tolerance business ethics Congratulations!! You now know the basics of OO (object- orientation). There are more odds and ends, which we will be discussing, but the basics have been covered. We now turn to: 2 Method body: sequence of statements (interspersed with declarations) to execute, in the order in which they appear /** Constructor: a chapter with title t, number n, previous chapter p */ public Chapter(String t, int n, Chapter p) { title= t; number= n; previous= p; } Execute the three assignments in the order in which they appear. Same scheme is used when a cook uses a recipe. 3 /* Put smaller of x, y in z */ if (x < y) { z= x; } else { z= y; } if statement /* swap x, y to put larger in y */ if (x < y) { int t; t= x; x= y; y= t; } Syntax: if (<boolean expression) <statement> Execution: if the <boolean expression> is true, then execute the
Background image of page 1

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

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

Page1 / 2

06-07feb08methods - C S100J 8 F ebruary 2 005 M eth o d b o...

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

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