410 likes | 555 Vues
Structured Problem Solving An Introduction. Stewart Blakeway blakews@hope.ac.uk 0151 291 3113. Aims of the presentation. to quickly list the skills to be developed on the SPS strand of the course to officially start the course. Skills to be developed in the SPS strand of the course.
E N D
Structured Problem Solving An Introduction Stewart Blakeway blakews@hope.ac.uk 0151 291 3113
Aims of the presentation • to quickly list the skills to be developed on the SPS strand of the course • to officially start the course
Skills to be developed in the SPS strand of the course The most important bit • Problem Solving Skills • Programming Skills • Team Interaction Skills • Presentation Skills • Reflective Skills
Skills to be developed in the SPS strand of the module • Problem Solving Skills • Programming Skills • Team Interaction Skills • Presentation Skills • Reflective Skills
Problem Solving Skills • Analysis of Problems • Crossing a busy road • Eating a Pie • Cooking a Pie • Climbing Mount Everest ?????? • Getting PieEater to do something complicated • Writing other software to do something complicated
Problem Solving Skills • Analysis of the Structure of Solutions • Sequence • Selection • Repetition
Problem Solving Skills • Structured English • Sequence • Selection • Repetition
Skills to be developed in the SPS strand of the module • Problem Solving Skills • Programming Skills • Team Interaction Skills • Presentation Skills • Reflective Skills
Programming Skills • Introduction to Java • Java Programming Constructs • Java Trainer • The PieEater • Java revisited • Object Oriented Concepts • BlueJ Integrated Development Environment • (http://www.bluej.org/about/what.html) • The PieEater again plus Close Friends • Graphics and Animation
Programming Skills • Data Structures • Selection of Appropriate Data Structures • Sorting • Searching
Skills to be developed in the SPS strand of the module • Problem Solving Skills • Programming Skills • Team Interaction Skills • Presentation Skills • Reflective Skills
Team Interaction Skills • Animation Problems • Solved in Groups • Coded in Groups • Tested in Groups
Skills to be developed in the SPS strand of the module • Problem Solving Skills • Programming Skills • Team Interaction Skills • Presentation Skills • Reflective Skills
Presentation Skills • Presentation of Working Animations • Demonstration of the Running Animation • Explanation of the Choice of Variables • Explanation of the Algorithmic Design • Explanation of the Data Structures Selected • Discussion of Possible Enhancements
Skills to be developed in the SPS strand of the module • Problem Solving Skills • Programming Skills • Team Interaction Skills • Presentation Skills • Reflective Skills
Reflective Skills • Reflect on Team Work Activities • Reflect on the Scope of the Task • Highlight Possible Failings in the Mechanics of the Team Work Activity • Suggest Possible Improvements to Team Work Interaction
Your First Seminar createpieeater(); pendown(); walk(); penup(); walk(); pendown(); turnright(); walk(); walk();
Let’s Loop-the-Loop No Semi Colons createpieeater(); while (test) { actions; } other actions; Sequences of Actions each Ending with a Semi Colon
Semi-colons: a working rule • Do not put them at the end of while() if () { } • Do put them at the end of other lines int a; a = 7; turnleft();
while (test) { } test • clearahead • direction != “SW” • pieinsight clearahead and pieinsight are either true or false direction != “SE” can be evaluated to either true or false
Loop Operation while (test) { actions; } other actions; Evaluate test true false
Test is True Body of Loop while (test) { • actions; } other actions; Enter Body of Loop Execute [actions;] Evaluate testAgain
Test is True while (test) { • actions; } other actions; Enter Body of Loop Execute [actions;] Evaluate testAgain
Test is True while (test) { • actions; } other actions; Enter Body of Loop Execute [actions;] Evaluate testAgain
Test is False while (test) { • actions; } other actions; Jump to other actions; and Continue with the Rest of the Program
{actions;} walk(); pendown(); penup(); turnleft(); turnright(); • You add the rest
Selection • The if statement allows us to specify alternative actions depending upon a test
Selection if (test) { }else { } if (pieinsight) { eatpie(); } else { walk(); }
if inside a loop createpieeater(); randompies(20); while (clearahead) { if (pieinsight) { eatpie(); } else { walk(); } }
Counting loops - for inti; createpieeater(); for (i=0; i<5; i++) { walk(); }
In Conclusion • Problem Solving is a Skill • Riding a Bicycle • Swimming • Keeping Awake in Lectures • It Cannot be Learned Quickly • It Cannot be Learned without Practice • Every Failure is Part of the Learning Process
Lecture Exercise 1 • Draw the following grid
Trace out the following program createpieeater(); turnright(); pendown(); while (clearahead) { walk(); }
Lecture Exercise 2 • Write the program for
Lecture Exercise 2 Answer createpieeater(); inti; for (i=1 ; i<=4 ; i++) { while (clearahead) { walk(); } turnright(); turnright(); }
Lecture Exercise 3 – spot the syntax error createpieeater(); inti; for (i=1 , i<=4 , i++) { while (clearahead) { walk() } turnright(); turnright();
In Conclusion • Programming Languages are Merciless • Syntax Matters • Semi Colons can be Dangerous • In Conclusion: }
Questions? • Next… • Problem Solving in your seminars • More loops • If statements • Next lecture on Algorithms • Setting of assessment next week