Download presentation
Presentation is loading. Please wait.
Published byGwendoline Blake Modified over 9 years ago
1
Graphics and Procedures Programming Right from the Start with Visual Basic.NET 1/e 5
2
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 2 Objectives Learn the Visual Logic graphics commands and how they work Appreciate the concept of structured design Know the process for creating procedures
3
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 3 Objectives (cont.) Understand the role of procedure arguments Realize the difference between formal arguments and actual arguments Develop and evaluate solutions that utilize graphics and procedures
4
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 4 5-1 Graphics Visual Logic graphics are a variation on Logo Programming Language, which has been used in educational settings for over three decades.
5
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 5 Forward and Turn Right The Forward command moves the pen a specified number of units. The Turn Right command rotates the drawing direction a specified number of degrees.
6
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 6 Using Loops Two Patterns Emerge… –Repetition of the commands Forward and Turn Right –The degrees the drawing direction must turn right are different for each shape and are based on the number of sides in the shape
7
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 7 5-2 Working with Color The pen draws with black ink and is 1 unit in width. Visual Logic provides commands for changing the pen’s color and width.
8
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 8 Set Color and Pen Width The Set Color command allows the developer to select any color from the standard color dialog box. The Pen Width command changes the thickness of the drawing pen.
9
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 9 Color Forward The Color Forward command moves the pen through the three base colors of red, green, and blue. The Color Forward command typically occurs inside a loop.
10
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 10 5-3 Structured Design Using Procedures Structured design means a problem is broken into smaller pieces, each of which is solved individually. A procedure is a series of instructions that are grouped together and treated as a single unit.
11
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 11 5-3 Structured Design Using Procedures (cont.)
12
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 12 Rotating Flags Problem
13
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 13 Rotating Flags Problem (cont.)
14
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 14 5-4 Procedures with Arguments An argument (or parameter) is a piece of information that is communicated between the calling code and the procedure. The argument is referred to as an actual argument at the time of the call and as a formal argument in the called procedure.
15
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 15 Rotating Shapes Program
16
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 16 Visual Logic Implementation
17
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 17 5-5 Recursion A recursive procedure is a procedure that calls itself. To prevent infinite recursion, a recursive procedure typically first performs a test on one of its arguments to check for a base case.
18
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 18 Chapter Summary Visual Logic graphics include commands, such as Forward and Right, that move a virtual pen across the screen. Procedures allow code to be written once and called many times. An actual argument is a value or reference passed from the calling code to a procedure.
19
Graphics and Procedures Programming Right from the Start with Visual Basic.NET 1/e 5
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.