Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual C++ Programming: Concepts and Projects Chapter 10B: Recursion (Tutorial)

Similar presentations


Presentation on theme: "Visual C++ Programming: Concepts and Projects Chapter 10B: Recursion (Tutorial)"— Presentation transcript:

1 Visual C++ Programming: Concepts and Projects Chapter 10B: Recursion (Tutorial)

2 Tutorial: Generating a Fractal Image Problem Analysis – This project uses the recursive DrawBranch() method – The result will be an interface upon which one branch, with its recursive subbranches, is drawn – On Your Own tasks will allow more options – The program can easily be developed to have four central branches Programming with Visual C++2

3 Problem Analysis Programming with Visual C++3

4 Design Interface – Menus are created using the MenuStrip control – Menu items are named after the text they contain – If the text is numeric, the menu item names default to numbered order – Menus control stopping the program and setting the maximum levels of recursion Programming with Visual C++4

5 Design (continued) Programming with Visual C++5

6 Design (continued) Programming with Visual C++6

7 Design (continued) Programming with Visual C++7

8 Design (continued) Programming with Visual C++8 Each menuItem requires a Click() event

9 Design (continued) Programming with Visual C++9 Instance variables

10 Design (continued) Programming with Visual C++10 Required Graphics and Drawing objects

11 Design (continued) Programming with Visual C++11 Data table for DrawBranch()

12 Design (continued) Programming with Visual C++12 Algorithms – For menu items that set maxLevels

13 Design (continued) Programming with Visual C++13 Algorithm for DrawFractal()

14 Design (continued) Programming with Visual C++14 Algorithm for method DrawBranch()

15 Design (continued) Programming with Visual C++15

16 Design (continued) Programming with Visual C++16

17 Design (continued) Programming with Visual C++17

18 Design (continued) Programming with Visual C++18

19 Design (continued) Programming with Visual C++19

20 Design (continued) Programming with Visual C++20

21 Design (continued) Programming with Visual C++21

22 Development Create the interface – Menus The menuStrip control is used to add menuStrip features to the program The “Type here” labels indicate where menu headings and items can be created Programming with Visual C++22

23 Development (continued) Programming with Visual C++23

24 Development (continued) Menus – Menu headings are placed at the top level of each menu – Menu items are listed below Programming with Visual C++24

25 Development (continued) Programming with Visual C++25

26 Development (continued) Programming with Visual C++26

27 Development (continued) Declare instance variables and objects Programming with Visual C++27

28 Development (continued) Initialization in Form1_Load() Programming with Visual C++28

29 Development (continued) Coding the Exit menu Programming with Visual C++29

30 Development (continued) Coding the level menu items Programming with Visual C++30

31 Development (continued) Programming with Visual C++31

32 Development (continued) Coding DrawFractal() Programming with Visual C++32

33 Development (continued) Calling DrawBranch() Programming with Visual C++33

34 Development (continued) Programming with Visual C++34

35 Testing Demonstrate that each level works correctly Demonstrate that the Exit menu works Programming with Visual C++35

36 Testing (continued) Programming with Visual C++36

37 Analysis The number of recursive calls is factorial The number of executions of DrawBranch() is O(3 n ) – n is maxLevels-1 This program would demand considerable resources to complete a drawing involving a high number of levels Programming with Visual C++37

38 Analysis (continued) Programming with Visual C++38

39 On Your Own More central branches – Add three more central branches Add an angle menu – Varying the angle produces different fractal images Programming with Visual C++39

40 On Your Own (continued) Programming with Visual C++40

41 On Your Own (continued) Programming with Visual C++41


Download ppt "Visual C++ Programming: Concepts and Projects Chapter 10B: Recursion (Tutorial)"

Similar presentations


Ads by Google