{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

06-07feb08methods

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

Info icon This 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 <statement>
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern