Presentation is loading. Please wait.

Presentation is loading. Please wait.

Phil Campbell London South Bank University

Similar presentations


Presentation on theme: "Phil Campbell London South Bank University"— Presentation transcript:

1 Phil Campbell London South Bank University
Pseudocode Process Modelling Phil Campbell London South Bank University

2 Phil Campbell London South Bank University
Pseudocode Simple explanation of the steps to achieve a task Can be reduced to Sequence Selection Iteration Step follows step Choose which steps to follow depending on some condition Repeat steps a number of times Phil Campbell London South Bank University

3 Phil Campbell London South Bank University
Sequence begin wake up get out of bed shower dress eat end begin wake up get out of bed //shower go to bathroom take shower towel dry dress eat end The order is important All steps must be done Each step may be expanded Phil Campbell London South Bank University

4 Phil Campbell London South Bank University
Selection begin if hungry then eat breakfast end if end begin if hungry then eat breakfast else drink coffee end if end hungry is either true or false hungry is a boolean condition Must either eat breakfast or drink coffee but not both. Phil Campbell London South Bank University

5 Phil Campbell London South Bank University
Selection begin if hungry then eat breakfast else drink coffee end if end begin if hungry=true then eat breakfast else drink coffee end if end hungry is either true or false hungry is a boolean condition Phil Campbell London South Bank University

6 Phil Campbell London South Bank University
Selection begin if hungry then eat breakfast else drink coffee end if end begin if hungry=false then eat breakfast else drink coffee end if end hungry is either true or false hungry is a boolean condition Phil Campbell London South Bank University

7 Phil Campbell London South Bank University
Selection begin select preference case cereal: check milk in fridge case sausages : get frying pan case eggs : check use by date case toast: open bread bin end select end One and only one of the preferred actions will take place. Phil Campbell London South Bank University

8 Phil Campbell London South Bank University
Iteration begin while hungry eat end while end As long as the hungry condition is true keep eating begin make toast for each slice of toast spread butter eat end for end Phil Campbell London South Bank University

9 Phil Campbell London South Bank University
Iteration begin move forward ... end begin while can move forward move forward end while end Phil Campbell London South Bank University

10 Phil Campbell London South Bank University
Storing Values begin total <- 0; for each student add one to total end for display " value is " total; end increment total total++ total <- total + 1 Count the number of students Phil Campbell London South Bank University

11 Phil Campbell London South Bank University
Storing Values begin totalHeight <- 0; count <- 0 for each student add student height to totalHeight increment count end for result <- totalHeight / count display "result is " result end Phil Campbell London South Bank University

12 Phil Campbell London South Bank University
begin totalHeight <- 0; count <- 0 for each student add student height to totalHeight increment count end for result <- totalHeight / count display "result is " result end 1.74 1.89 1.62 Student Heights totalHeight 5.25 3.63 1.74 count 3 2 1 1.75 result Result is 1.75 find the average height of a set of students Phil Campbell London South Bank University

13 Phil Campbell London South Bank University
UML Activity Diagram wake up get out of bed shower dress eat begin wake up get out of bed shower dress eat end Phil Campbell London South Bank University

14 Phil Campbell London South Bank University
UML Activity Diagram [not hungry] eat breakfast [hungry] begin if hungry then eat breakfast end if end Phil Campbell London South Bank University

15 Phil Campbell London South Bank University
UML Activity Diagram eat breakfast drink coffee [hungry] [not hungry] begin if hungry then eat breakfast else drink coffee end if end Phil Campbell London South Bank University

16 Phil Campbell London South Bank University
UML Activity Diagram eat [hungry] [not hungry] begin while hungry eat end while end Phil Campbell London South Bank University

17 Answer to robot (general)
begin while not at target turn left while not can move turn right end while move forward end Phil Campbell London South Bank University

18 Phil Campbell London South Bank University
Robot class Phil Campbell London South Bank University


Download ppt "Phil Campbell London South Bank University"

Similar presentations


Ads by Google