Chapter 2 - Introduction to Java Applications

2 1 Chapter 2 - Introduction to Java Applications              ) *  )  *         E F...
Author: May Williamson
0 downloads 3 Views 612KB Size
2

1

Chapter 2 - Introduction to Java Applications 































)

*



)



*



















E

F



+

G

Y



,

Z

H

[

I

Z

J

K

I

L

.

/

/

M

\

s

t

u

t

^

]

x

y

ˆ

‰

Š

ž

Ÿ

 

­

®

¯

¸

¹

Ò

Ó

z

{

‹

Œ

}



¡

»

²

³

¼

Ï

¾

Ü

¿

¾

÷

ø

ù

ú

û

ü

ý

þ

ù

ÿ

û

ø

ñ

Ù

Â

À

Ñ

Û

Û

Ü

Û

‹

T

U

V

m

e





7



8

g



9

—

m

:

z



;

˜

“

0

$

2

3



%




G

B

H

G

E

W

`

[

a

`

^

• Upcoming program

• Sample GUI +

8

#

$

%

&

'

(

)

1

2

0

3

4

1

5

6

– – – – *

 2002 Prentice Hall. All rights reserved.

Application that uses dialog boxes Explanation will come afterwards Demonstrate another way to display output Packages, methods and GUI

 2002 Prentice Hall. All rights reserved.

23 I

1 1 2 3 2 4 3 5 6 4 7 8 5 9 6 10 11 7 12 13 8 14 15 9

J

K

L

M

N

24

O

// // Fig. Fig. 2.6: 2.6: Welcome4.java Welcome4.java // Printing multiple lines in a dialog box // Printing multiple lines in a dialog box // Java extension packages import javax.swing.JOptionPane; import javax.swing.JOptionPane;

// import class JOptionPane // import class JOptionPane

public class Welcome4 { public class Welcome4 { // main method begins execution of Java application public static void main( String args] ) public static void main( String args[] ) {{ JOptionPane.showMessageDialog( JOptionPane.showMessageDialog( null, "Welcome\nto\nJava\nProgramming!" );

1610 17 1811 19 } 12

null, "Welcome\nto\nJava\nProgramming!" System.exit( 0 ); // terminate application); }

// end method main System.exit( 0 ); // terminate the program // end class Welcome4 }

P

Q

R

S

T

U

V

W

X

Y

T

Z

[

\

]

^

_

T

Z

X

S

T

X

Welcome4.java

– Lines 1-2: comments as before

1. import statement 4

2. Class Welcome4 2.1 main

• Begin with java • Included with Java 2 Software Development Kit

2.2 showMessageDialo g

– Extension packages • Begin with javax • New Java packages

2.3 System.exit

Program Output

// Java extension packages

– Two groups of packages in Java API – Core packages

5

import javax.swing.JOptionPane;

– import statements • Used by compiler to identify and locate classes used in Java programs • Tells compiler to load class JOptionPane from javax.swing package  2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

4

25 b

c

d

e

f

g

h

i

j

k

f

l

m

n

o

p

q

f

l

j

e

f

j

i

r

m

s

r

26

p

b

– Lines 6-11: Blank line, begin class Welcome4 and main 12 13

c

d

e

f

g

h

i

j

k

f

l

m

n

o

p

q

f

l

j

e

f

j

i

r

m

s

r

p

– All statements end with ; • A single statement can span multiple lines • Cannot split statement in middle of identifier or string

JOptionPane.showMessageDialog( null, "Welcome\nto\nJava\nProgramming!" );

– Executing lines 12 and 13 displays the dialog box

– Call method showMessageDialog of class JOptionPane • Requires two arguments • Multiple arguments separated by commas (,) • For now, first argument always null • Second argument is string to display – showMessageDialog is a static method of class JOptionPane • static methods called using class name, dot (.) then method name

• Automatically includes an OK button – Hides or dismisses dialog box • Title bar has string Message

 2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

27

28 t

b

c

d

e

f

g

h

i

j

k

f

l

m

n

o

p

q

f

l

j

e

f

j

i

r

m

s

r

u

v

w

x

y

z

{

|

}

~



€

ˆ

15



w





‚

ƒ

„



z

ƒ

y

x

…

w

†

†

ƒ

x

‡

p

‰

Š

‹

Œ

‹



Ž

• Upcoming program

System.exit( 0 );

– Calls static method exit of class System

– Use input dialogs to input two values from user – Use message dialog to display sum of the two values

• Terminates application – Use with any application displaying a GUI • Because method is static, needs class name and dot (.) • Identifiers starting with capital letters usually class names

– Argument of 0 means application ended successfully • Non-zero usually means an error occurred

– Class System part of package java.lang • No import statement needed • java.lang automatically imported in every Java program

– Lines 17-19: Braces to end Welcome4 and main

 2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

29 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32



‘

’

“

”

30

•



–

–

—

˜

™

š

// Fig. 2.9: Addition.java // An addition program. ›

// Java extension packages import javax.swing.JOptionPane;

œ

Addition.java 

‘

’

“

”

•

ž

// import class JOptionPane Ÿ

 

System.exit( 0 ); ¡

// terminate application

¢

public class Addition {

Declare variables: name and data type. Input first integer as a String, assign // main method begins execution of Java application to firstNumber. public static void main( String args[] )



// display the results JOptionPane.showMessageDialog( null, "The sum is " + sum, "Results", JOptionPane.PLAIN_MESSAGE );

£

¤

} ¥

// end method main

§

¦

¨

}

// end class Addition

Program output

{ String firstNumber; String secondNumber; int number1; int number2; int sum;

// // // // //

first string entered by user second string entered by user first number to add second number to add sum of number1 and number2

// read in first number from user as a String firstNumber = JOptionPane.showInputDialog( "Enter first integer" ); // read in second number from user as a String secondNumber = Convert strings to integers. JOptionPane.showInputDialog( "Enter second integer" );

Add, // convert numbers from type String toplace type result int in sum. number1 = Integer.parseInt( firstNumber ); number2 = Integer.parseInt( secondNumber ); // add the numbers sum = number1 + number2;

1. import 2. class Addition 2.1 Declare variables (name and data type) 3. showInputDialog 4. parseInt 5. Add numbers, put result in sum  2002 Prentice Hall.

 2002 Prentice Hall.

All rights reserved.

All rights reserved.

5

31 ©

ª

«

¬

­

®

¯

°

±

²

³

´

µ

´

½

5

¬

¾

¿



À



Á

À

·

Â

¸

¹

´

¯

¸

®

­

º

¬

»

»

¸

­

¼

Ä

Å

Ç

12 13

¿

É

À

Â

Ê

Ë

Ì

Ë

Ç

¾

¿

Í

À

Í

Á

À

Î

Â

Ï

Ð

Ë

¿

Ï

È

¾

Ñ

Ç

Ò

Ò

Ï

32

¾

Á

Ã

// first string entered by user // second string entered by user

– Variables

public class Addition {

• Location in memory that stores a value – Declare with name and data type before use • firstNumber and secondNumber are of data type String (package java.lang)

– Begins public class Addition • Recall that file name must be Addition.java

– Lines 10-11: main String firstNumber; String secondNumber;

È

String firstNumber; String secondNumber;

– Location of JOptionPane for use in the program

12 13

¾

½

import javax.swing.JOptionPane;

7

Æ

Ã

– Hold strings • Variable name: any valid identifier • Declarations end with semicolons ;

// first string entered by user // second string entered by user

– Declaration

String firstNumber, secondNumber;

• firstNumber and secondNumber are variables

– Can declare multiple variables of the same type at a time – Use comma separated list

– Can add comments to describe purpose of variables  2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

33 Ä

Å

Æ

Ç

¾

È

¿

É

À

Â

Ê

Ë

Ì

Ë

½

14 15 16

int number1; int number2; int sum;

Ç

¾

¿

Í

À

Í

Á

À

Î

Â

Ï

Ð

Ë

¿

Ï

È

¾

Ñ

Ç

Ò

Ò

Ï

¾

34

Á

Ä

Å

Æ

Ç

¾

È

¿

É

À

Â

Ê

Ë

Ì

Ã

Ë

½

19 20

// first number to add // second number to add // sum of number1 and number2

Ç

¾

¿

Í

À

Í

Á

À

Î

Â

Ï

Ð

Ë

¿

Ï

È

¾

Ñ

Ç

Ò

Ò

Ï

¾

Á

Ã

firstNumber = JOptionPane.showInputDialog( "Enter first integer" );

– Reads String from the user, representing the first number to be added

– Declares variables number1, number2, and sum of type int

• Method JOptionPane.showInputDialog displays the following:

• int holds integer values (whole numbers): i.e., 0, -4, 97 • Data types float and double can hold decimal numbers • Data type char can hold a single character: i.e., x, $, \n, 7 • Primitive data types - more in Chapter 4

• Message called a prompt - directs user to perform an action • Argument appears as prompt text , • If wrong type of data entered (non-integer) or click error occurs Ó

 2002 Prentice Hall. All rights reserved.

Ô

Õ

Ö

×

 2002 Prentice Hall. All rights reserved.

35 Ù

Ú

Û

Ü

Ý

Þ

ß

à

á

â

ã

ä

å

í

19 20

Ø

ä

î

Ü

ï

ð

æ

ñ

æ

ð

ò

ç

è

é

ä

ß

è

Þ

Ý

ê

Ü

ë

ë

è

Ý

ì

ô

õ

ö

÷

î

ø

ï

ù

ð

ò

ó

firstNumber = JOptionPane.showInputDialog( "Enter first integer" );

ú

û

ü

í

23 24

û

î

÷

ï

ð

ý

ñ

ý

ð

ò

þ

ÿ

û

ï

ÿ

ø

î



÷





ÿ

î

ñ

36

ó

secondNumber = JOptionPane.showInputDialog( "Enter second integer" );

– Similar to previous statement – Result of call to showInputDialog given to firstNumber using assignment operator = • Assignment statement • = binary operator - takes two operands – Expression on right evaluated and assigned to variable on left • Read as: firstNumber gets value of JOptionPane.showInputDialog( "Enter first integer" )

• Assigns variable secondNumber to second integer input 27 28

number1 = Integer.parseInt( firstNumber ); number2 = Integer.parseInt( secondNumber );

– Method Integer.parseInt • Converts String argument into an integer (type int) – Class Integer in java.lang • Integer returned by Integer.parseInt is assigned to variable number1 (line 27) – Remember that number1 was declared as type int • Line 28 similar

 2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

6

37 



























31















































38









































sum = number1 + number2; 



















































JOptionPane.showMessageDialog( null, "The sum is " + sum, "Results", JOptionPane.PLAIN_MESSAGE ); 

– Assignment statement • • • •

Calculates sum of number1 and number2 (right hand side) Uses assignment operator = to assign result to variable sum Read as: sum gets the value of number1 + number2 number1 and number2 are operands

– Use showMessageDialog to display results – "The sum is " + sum • Uses the operator + to "add" the string literal "The sum is" and sum • Concatenation of a String and another data type – Results in a new string • If sum contains 117, then "The sum is " + sum results in the new string "The sum is 117" • Note the space in "The sum is " • More on strings in Chapter 10

 2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

39 

!

"

#

$

%

&

'

(

)

*

+

3

;

:




?

@

A

B

C

D

E

F

G

H

I

J

9

I

R

JOptionPane.showMessageDialog( null, "The sum is " + sum, "Results", JOptionPane.PLAIN_MESSAGE ); T

– Different version of showMessageDialog

U

V

V

W

X

U

Y

Z

W

[

\

X

]

^

_

A

B

D

K

F

Q

U

K

`

F

a

b

L

G

c

D

M

C

B

O

A

P

P

M

B

Q

e

f

g

h

i

j

k

i

l

m

Displays a dialog that indicates an error to the user.

JOptionPane.INFORMATION_MESSAGE

Displays a dialog with an informational message to the user. The user can simply dismiss the dialog.

JOptionPane.WARNING_MESSAGE

Displays a dialog that warns the user of a potential problem.

JOptionPane.QUESTION_MESSAGE

Displays a dialog that poses a question to the user. This dialog normally requires a response, such as clicking on a Yes or a No button.

o

p

q

r

q

s

no icon

Displays a dialog that simply contains a message, with no icon.

r

JOptionPane

 2002 Prentice Hall. All rights reserved.

I

JOptionPane.ERROR_MESSAGE

JOptionPane.PLAIN_MESSAGE n

N

d

• Requires four arguments (instead of two as before) • First argument: null for now • Second: string to display • Third: string in title bar • Fourth: type of message dialog with icon – Line 36 no icon: JoptionPane.PLAIN_MESSAGE

M

S

t

u

v

w

x

y

v

x

w

z

u

{

|

}

w

w

y

~

}



€

y



u

~

w

‚

 2002 Prentice Hall. All rights reserved.

42

41 ƒ

„

…

†

‡

ˆ

‰

Š

‹

Œ

‰



Ž

‡





‘

• Variables – Every variable has a name, a type, a size and a value • Name corresponds to location in memory

– When new value is placed into a variable, replaces (and destroys) previous value – Reading variables from memory does not change them

ƒ

„

…

†

‡

ˆ

‰

Š

‹

Œ

‰



Ž

‡





‘

• Visual Representation – Sum = 0; number1 = 1; number2 = 2; sum

0

– Sum = number1 + number2; after execution of statement

sum

 2002 Prentice Hall. All rights reserved.

3

 2002 Prentice Hall. All rights reserved.

7

43 ’

“

”

•

–

—

˜

™

š

›

˜

—

44

œ

’

• Arithmetic calculations used in most programs

“

”

•

–

—

˜

™

š

›

˜

—

œ

• Operator precedence

– Usage

– Some arithmetic operators act before others (i.e., multiplication before addition)

• * for multiplication • / for division • +, • No operator for exponentiation (more in Chapter 5)

• Use parenthesis when needed

– Example: Find the average of three variables a, b and c • Do not use: a + b + c / 3 • Use: (a + b + c ) / 3

– Integer division truncates remainder 7 / 5 evaluates to 1

– Follows PEMDAS

– Modulus operator % returns the remainder

• Parentheses, Exponents, Multiplication, Division, Addition, Subtraction

7 % 5 evaluates to 2

 2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

46

45 Û

’

“

”

•

–

—

˜

™

š

›

˜

—

Ü

Ý

Þ

ß

à

ñ



ž

Ÿ

 

¡

¢

£

 

¤

¥

¦

§

¨

©

ª

«

¬

­

®

¯

°

±

²

( )

Parentheses

*, / and %

Multiplication Division Modulus Addition Subtraction

+ or -

Ä

Å

Æ

Ç

È

Ç

É

Ê

Ë

Ì

Í

Î

Í

Ï

Í

Ð

Î

Í

Ñ

Ò

Ó

Ì

Ô

Õ

³

´

µ



´

·

¸



¹

º

»

¼

º

½

¾

·

¿

À

Á

´



Â



µ



¿

Â



×

Í

Õ

Ô

Î

Ñ

Ø

Í

Ì

Ó

Õ

Ñ

Ì

Ù

ò

â

á

ó

ã

ô

ä

õ

ö

å

÷

ø

æ

ô

ç

ó

á

ù

ä

è

ú

é

û

ê

ü

ý

ë

ì

þ

ÿ

æ

í

á

î

ï

æ

ä

ð

ü

• if control structure Ã

Evaluated first. If the parentheses are nested, the expression in the innermost pair is evaluated first. If there are several pairs of parentheses on the same level (i.e., not nested), they are evaluated left to right. Evaluated second. If there are several of this type of operator, they are evaluated from left to right. Evaluated last. If there are several of this type of operator, they are evaluated from left to right. Ö

á

œ

– Simple version in this section, more detail later – If a condition is true, then the body of the if statement executed • 0 interpreted as false, non-zero is true

– Control always resumes after the if structure – Conditions for if structures can be formed using equality or relational operators (next slide) if ( condition ) statement executed if condition true

Ú

• No semicolon needed after condition – Else conditional task not performed

 2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

48

47 































!

"

#

$



%

&

:

'

(

;


< f

g

’ h

i

j

k

j

l

m

n

o

p

q

r

s

t

u

q

v

w







=

@



>

;

?

B

;



@

A

;

D

;





A

E

=

1





=

Equality operators =







B









C

H







I

J





K



L

M













N

Z

a

F

O

P

T

O

Q

R

S



Y

@





[

[

b

















\

[

]

c

\

^

_

\

_

`

d

]

e

]

_

\

R

B

E

D

E

U

V

W

X

W

O

U

== !=

x == y x != y

x is equal to y x is not equal to y

> < >= y < y >= y number2 ) result = result + "\n" + number1 + " > " + number2;

4. showMessageDialog

if ( number1 = number2 ) result = result + "\n" + number1 + " >= " + number2; // Display results JOptionPane.showMessageDialog( null, result, "Comparison Results", JOptionPane.INFORMATION_MESSAGE ); System.exit( 0 ); } }

// terminate application

// end method main

Notice use of JOptionPane.INFORMATION_MESSAGE

// end class Comparison

 2002 Prentice Hall.

 2002 Prentice Hall.

All rights reserved.

All rights reserved.

51 Œ



Ž





‘

’

¢

“

’

£

¤

”

•

¥

¦

–

§

¨

—

©

˜

¥

’

¤

•

™

ª

š

«

›

¬

­

œ



®

¯

—

°

ž

­

’

Ÿ

 

—

•

52

¡

²

´

µ

¬



·

Ã

– Lines 1-12: Comments, import JOptionPane, begin class Comparison and main – Lines 13-17: declare variables

32

±

·

¬

À

°

¸

®

¯

¹

·

°

®

¸

º

®

·

À

¸

»

ª

¼

«

½

¬

­

¾

¿

®

¯

®

°

À

­

·

¯

Á

®

¸

Â

±

result = "";

– Initialize result with empty string

• Can use comma-separated lists instead: 13 14 15

³

±

34 35

if ( number1 == number2 ) result = number1 + " == " + number2;

String firstNumber, secondNumber, result;

– if structure to test for equality using (==) • If variables equal (condition true) – result concatenated using + operator – result = result + other strings – Right side evaluated first, new string assigned to result

– Lines 20-29: obtain user-input numbers and parses input string into integer variables

• If variables not equal, statement skipped

 2002 Prentice Hall. All rights reserved.

²

³

´

µ

¬



Ã

·

 2002 Prentice Hall. All rights reserved.

¬

±

·

À

®

°

¸

¯

·

¹

°

¸

®

®

º

À

·

ª

¸

»

«

¼

¬

½

­

®

¾

¿

¯

°

®

­

À

·

¯

Á

®

¸

Â

53 ²

´

µ

¬



±

¬

·

À

°

¸

®

¯

¹

·

°

®

¸

º

®

·

À

¸

ª

»

¼

«

½

¬

­

¾

®

¿

¯

®

°

À

­

·

¯

Á

®

¸

54 Â

±

• Precedence of operators – All operators except for = (assignment) associates from left to right

• If number1 = 123 and number2 = 123 – Line 34 evaluates true (if number1 = = number 2) • Because number1 equals number2 – Line 40 evaluates false (if number1 < number 2) • Because number1 is not less than number2 – Line 49 evaluates true (if number1 >= number2) • Because number1 is greater than or equal to number2

– Lines 50-52: result displayed in a dialog box using showMessageDialog

·

Ã

– Lines 37-50: other if structures testing for less than, more than, etc.

 2002 Prentice Hall. All rights reserved.

³

±

• For example: x = y = z is evaluated x = (y = z) Ä

Å

() * + < == =

Æ

Ù

Ú

Û

Ç

È

É

Ê

Ç

Ë

Ì

Ü

/ % != Ý

Ü

Ý

Þ

ö

>=

ß

÷

ø

ù

à

ú

á

â

ø

ø

á

û

Í

Í

Î

Ï

Ð

Ñ

Ò

Ð

Ó

Ð

Ò

Ô

Õ

left to right left to right left to right left to right left to right right to left ã

ö

á

ø

ä

ü

â

á

ý

þ

å

ä

ã

å

æ

æ

ç

Ö

×

Ø

â

parentheses multiplicative additive relational equality assignment è

å

é

ê

ë

ê

ì

í

î

ï

ì

ð

ñ

î

ò

ñ

ó

ô

ì

î

ó

õ

ÿ

 2002 Prentice Hall. All rights reserved.

9

55 























!

"





#



$



%



&

'



(

'



(





)



*









+



,



-





.











&





/



%







&





56



0

1

(

2

3

4

• Emphasize object-oriented programming (OOP) • Object-oriented design (OOD) implementation

I

J

>

4

5

K

6

6

=

L

7

8

M

9

N

:

:

;




?

G

6

6

E

@

A

>

B

P

C

Q

D

8

E

I

;

>

;

>

7

9

F

7

O

9

G

?

6

:

6

:

H

6

>

6

>

I

8

O

@

>

6

9

6

• Program Goal – Software simulator application – 2-floor elevator simulator

– Chapters 3 to 13, 15, 22 – Appendices G, H, I

• Models actual elevator operation

– Elevator graphics displayed to user – Graphical user interface (GUI) • User can control elevator

 2002 Prentice Hall. All rights reserved.

 2002 Prentice Hall. All rights reserved.

57 0

1

2

3

4

I

J

>

4

5

K

6

6

=

L

7

8

M

9

N

:

:

;




?

G

6

6

E

@

A

>

B

P

C

Q

D

8

E

I

;

7

9

>

F

7

O

9

G

?

6

H

:

6

I

>

8

O

@

>

58

6

9

0

1

6

2

3

4

I

J

>

4

5

K

6

6

=

L

7

8

M

9

N

:

:

;




?

G

6

6

E

@

A

>

B

P

C

Q

D

8

E

I

7

9

F

7

O

9

G

?

H

I

8

O

@

>

6

9

6

• Application GUI

• Elevator Simulation

– First Floor/Second Floor buttons create person on respective floors

– Model people using elevator – Elevator door, floor door, elevator button, floor button, elevator shaft, bell, floor, backgrounds

• Disable button if floor occupied by a person already • Unlimited number of passenger creations

• Operate accordingly or by request to avoid “injuring” person and make useless operations

– Animation requirements • Passenger walking and pressing floor button • Elevator moving, doors opening and closing • Illumination of elevator lights and buttons during operation

– Create person objects – Simulation rules • Elevator visits floor which person requests for elevator service • One person per elevator • 5 seconds to move from floors

– Incorporating sounds • • • •

 2002 Prentice Hall. All rights reserved.

Footsteps when person walks Button pressing clicks Elevator bell rings upon elevator arrival, elevator music Doors creak when opening and closing

 2002 Prentice Hall. All rights reserved.

59 0

1

4

3

I

2

J

>

K

4

5

6

=

6

L

M

7

8

N

9

:

:

O

;




?

6

E

6

>

@

A

P

B

Q

C

8

D

I

E

;

>

9

O

7

F

7

?

9

G

6

:

H

6

>

I

O

8

>

@

9

• Designing elevator system – Specified in requirements document through OOD analysis • UML • Design used to implement Java code – How system should be constructed to complete tasks

• System Structure – System is a set of interactive components to solve problems • Simplified by subsystems – Simulator (through ch. 15), GUI (ch. 12 and 13, display (ch. 22) – Describes system’s objects and inter-relationships – System behavior describes how system changes through object interaction

 2002 Prentice Hall. All rights reserved.

6

6

60 0

1

4

3

I

2

J

>

K

4

5

6

=

6

L

M

7

8

N

9

:

:

;

O




?

6

E

6

>

@

A

P

B

Q

C

8

D

I

E

;

>

9

O

7

F

7

?

9

G

6

:

H

6

>

I

O

8

>

@

9

6

6

• UML diagram types – System structure • Class diagram (section 3.8) – Models classes, or “building blocks” of a system – Person, elevator, floor, etc. • Object diagrams (section 3.8) – Snapshot (model) of system’s objects and relationships at specific point in time • Component diagrams (section 13.17) – Model components such as graphics resources and class packages that make up the system • Deployment diagrams (not discussed) – Model hardware, memory and runtime resources

 2002 Prentice Hall. All rights reserved.

10

61 R

S

V

U

l

T

m

`

n

V

W

X

_

X

o

p

Y

Z

q

[

\

\

]

r

^

i

[

\

i

[

_

j

`

a

X

g

X

`

b

c

s

d

t

e

Z

f

l

g

]

`

[

r

Y

h

i

a

[

j

X

\

k

X

`

l

r

Z

`

b

[

X

X

– System behavior • Statechart diagrams (section 5.11) – Model how object changes state • Condition/behavior of an object at a specific time • Activity diagrams (section 5.11) – Flowchart modeling order and actions performed by object • Collaboration diagrams (section 7.10) – Emphasize what interactions occur • Sequence diagrams (section 15.12) – Emphasize when interactions occur • Use-case diagrams (section 12.16) – Represent interaction between user and system • Clicking elevator button  2002 Prentice Hall. All rights reserved.

11