Using if, elseif, else keywords we can build is-elseif-else ladder.
ifElseLadder.txt
@startuml
title "Student grade"
start
if (marks < 35) then (yes)
:Print 'You are failed';
elseif (marks < 50) then (yes)
:Print 'You are passed and got third class';
elseif (marks < 60) then (yes)
:Print 'You are passed and got second class';
elseif (marks < 70) then (yes)
:Print 'You are passed and got first class';
else (no case matched)
:Print 'You are passed and got distinction';
endif
stop
@enduml
Above snippet generate below diagram.
By default , the diagram is in horizontal mode, you can change it to vertical mode using the command ‘!pragma useVerticalIf on’
verticalMode.txt
@startuml
title "Student grade"
!pragma useVerticalIf on
start
if (marks < 35) then (yes)
:Print 'You are failed';
elseif (marks < 50) then (yes)
:Print 'You are passed and got third class';
elseif (marks < 60) then (yes)
:Print 'You are passed and got second class';
elseif (marks < 70) then (yes)
:Print 'You are passed and got first class';
else (no case matched)
:Print 'You are passed and got distinction';
endif
stop
@enduml
Above snippet generate below diagram.
Previous Next Home
No comments:
Post a Comment