Download presentation
Presentation is loading. Please wait.
1
ISQA 360 – July 8, 2002 Methods Dr. Sergio Davalos
2
Methods What is a method Syntax Using methods Control Structures
3
What is a method Procedures Similarities between program segments Same code small changes Public static type name (parameters Class NameofClass extends Object No Static – instance Referencing – calling invoking – qualifier
4
Structure Heading Body Return Public static void main( )
5
Aspects of methods Local variable – example page 173 Calling argument – parameters, number and type Alias Copy of value
6
Show me Fig. 4.4 page 189 Class Sphere extends Object Public static double volume (double value1) Fig 4.5 import ann.easyio.*; Import Sphere; Class SphereWorld extends Object ( Public static void Snam (String [] args] )
7
Methods Control Structures Selection Repetion Selection if then else Public static double minmum(double first, double second) ( If (first < second) return first; Else return second; ) If else if else if - page 221
8
Repetition N! = 1 if n = 0, = 1X2X … n if n >0 Public static int fact( int n) ( Int product = 1: For (int count=2; count <= n; count ++) Product *= count; Return product; ) Page 228 – fig 5.4, 5.5
9
Other Forever loop For (;;) Termination condition If (boolean epression) break; Sentienl – flag Post-test Pre-test Fig 5.7 – example Instance method/ new instance
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.