Slides - Chapter 9

Slides - Chapter 9 - Chapter 9 Structures and Sequential...

Info iconThis preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 9 Structures and Sequential Files BMGT 302 Business Application Programming 1 Structures Structure statement : used to create your own data type User-defined data types (or structures ): data types created by using the Structure statement Member variables : variables defined within a structure Structure can include member variables of: Any standard data types Other structure types Used to group related items into one unit Usually declared in the forms Declarations section 2 Structures (cont'd.) How to define a structure 3 Declaring a Structure Variable Structure statement only creates the data type It does not reserve memory locations Structure variables : variables declared using a structure How to declare a structure variable 4 Declaring a Structure Variable (cont'd.) Refer to an entire structure in code using its name Refer to a member variable using the structure name with the dot operator and the member variable name structureVariable.memberVariable Member access operator (a period) Member variables can be used like any other variables 5 Declaring a Structure Variable (cont'd.) How to use a member variable 6 Passing a Structure Variable to a Procedure Sample application Determine the amount of water required to fill a rectangular pool Program without using a structure Sample run of the Willow Pools application 7 Code for the Willow Pools application (without a structure) 8 Code for the Willow Pools application (with a structure) 9 Passing a Structure Variable to a Procedure (cont'd.) When you pass a structure variable to a procedure, all of its member variables are automatically passed Sample application using a structure: Uses less code to pass a structure variable to a procedure Stores all of the data in a single unit 10 Creating an Array of Structure Variables Use a one-dimensional array of structure variables Each element in the array is a structure variable Sample run of the Treasures Gift Shop application 11 Partial code for the Treasures Gift Shop application 12 Partial code for the Treasures Gift Shop application (contd.) Creating an Array of Structure Variables (contd.) 13 In-class exercise Demo 9-1 14 File Types Output files : files to which information is written Input files : files that are read by the computer Sequential access files ( text files ) composed of text that are both read and written sequentially, one line at a time Random access files Data can be accessed in any order Can jump to any item without reading the preceding items 15 Think of songs on a tape and an iPod Writing Data to a...
View Full Document

This note was uploaded on 12/02/2011 for the course BMGT 302 taught by Professor Huang during the Fall '11 term at Maryland.

Page1 / 63

Slides - Chapter 9 - Chapter 9 Structures and Sequential...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online