Download presentation
Presentation is loading. Please wait.
1
Data Types and Structures
SOFTWARE DESIGN AND DEVELOPMENT
2
INTRODUCTION Computer programs of all types (games, business applications, apps on your phone, bespoke systems, websites) store and manipulate data Text, whole numbers, decimal numbers and true/false
3
DATA TYPES AND STRUCTURES
The Course Support Notes for Higher Computing Science state that you should have knowledge and understanding of the following: string numeric (integer and real values) Boolean variables 1-D arrays, records sequential files (open, create, read, write and close)
4
Simple Data Types BOOLEAN
A BOOLEAN can have one of two values at any one time: True or False Stored using a single bit which is on (True) or off (False)
5
Simple Data Types CHARACTER
A CHARACTER is a single character from the keyboard or other input device Stored using ASCII or Unicode
6
Simple Data Types INTEGER
An INTEGER is a numerical value which has no decimal point An INTEGER can be positive or negative including zero e.g. 7, -89, 0, 4000 Stored using two’s compliment notation
7
Simple Data Types REAL A REAL is a numerical value which includes a decimal point e.g , -89.4, 0.004 Stored using floating point notation which uses an exponent and a mantissa
8
Simple Data Types STRING
A STRING is a collection of characters taken for example from the keyboard e.g. “Mr Ross”, “table”, telephone number ( ) Stored as a ‘special’ sort of array of characters
9
Simple Data Types: How would you store the following?
Runners name Runners time Runner qualified Runners class (e.g. A, B or C) STRING REAL BOOLEAN CHARACTER
10
CANDY CRUSH
11
EBAY app
12
RBS APP
13
Activities Complete Activities 1, 2 and 3 of the Data Types and Structures Worksheet
14
PROGRAMMING TASK Working with a partner, complete Activity 1 of the Data Types and Structures Programs sheet.
15
DATA TYPES AND STRUCTURES
The Course Support Notes for Higher Computing Science state that you should have knowledge and understanding of the following: string numeric (integer and real values) Boolean variables 1-D arrays, records sequential files (open, create, read, write and close)
16
Storing lots of data of a single type
Most software applications require large amounts of data to be stored. It is not practical to give every item of data a unique variable
17
Storing lots of data of a single type(cont)
We use a structure called an ARRAY to store a number of items of the same data type. Programs access items in an array via a single identifier and an index into the array. Array Index
18
DECLARING AN ARRAY IN VISUAL BASIC
An array is declared in a very similar manner to a standard variable declaration Only difference is that you also specify the number of elements you want in your array
19
Storing lots of data of a single type(cont)
Consider the following array of strings names: John Paula Kevin Andrea Ian (0) (1) (2) (3) (4) Each element in the array can be referred to using the array name with the index in brackets after the name e.g. names(1) refers to Paula names(4) refers to Ian
20
Storing lots of data of a single type(cont)
names John Paula Kevin Andrea Ian (0) (1) (2) (3) (4) A FOR loop could be used to print out the array above FOR counter FROM 0 TO 4 DO SEND names[counter] TO DISPLAY END FOR
21
String (a special sort of array)
A STRING is just a special sort of array A STRING is an array of CHARACTERS Some programming languages let you access the contents of a string like an array: SET newString TO “This is a string of characters” SEND newString[8] TO DISPLAY
22
Structured Data Types: How would you store the following?
ARRAY of STRING ARRAY OF REAL ARRAY OF BOOLEAN List of runners names List of runners times List of runners who qualified
23
ActivitY Complete Activity 4 of the Data Types and Structures Worksheet.
25
Storing more than one type of related data
Parallel Arrays: SET runners TO [“Fred”, “John”, “Sophie”, “Anne”, “Mike”] SET times TO [4.32, 4.56, 4.31, 5.01, 4.45] SET qualified TO [true, false, true, false, true] Sophie’s details: runners[2], times[2] and qualified[2] You could use a FOR loop to process all 5 records
26
DATA TYPES AND STRUCTURES
The Course Support Notes for Higher Computing Science state that you should have knowledge and understanding of the following: string numeric (integer and real values) Boolean variables 1-D arrays, records sequential files (open, create, read, write and close)
27
Storing in a record A more intuitive way to store related data is in a record A record stores all the details of a single runner together Store all runners details in an array of records STRUCTURE runner IS RECORD {STRING name, REAL time, BOOLEAN qualified} SET runner[0] TO {name = “Fred”, time = 4.32, qualified = True} SET runner[1] TO {name = “John”, time = 4.56, qualified = False}
28
Activity Please complete Activity 5 of the Data Types and Structures Worksheet.
30
In application storage
The majority, if not all, applications which you are familiar with using will contain data stored in records
31
In application storage (game)
32
ADVANTAGES OF RECORDS Records can keep data together in a structured way. When storing lists of data about a person or thing, it makes sure that the data is held together and identified as a single item in the program.
33
Records in VB A user defined data type:
34
DOT NOTATION Records use dot notation, so each element of the record is accessed by giving the record's name followed by a dot and the element of the record.
35
An array of records in VB
36
In application storage (Database)
37
Visual Basic setup Toolbox Error List Default File Saving Location
38
Create a STRUCTURE, POPULATE AND PRINT
Using Visual Basic: Create a Structure to store data of the types shown below Create an array of enough size of the type of that Structure Populate the array with the following data Print the data to the screen
39
Write a program to store the CAMERA data in an ARRAY OF A structure and display it in a listbox
40
Modify the program to allow you TO change the details of an entry IN THE LIST BOX AND DISPLAY IT AGAIN TIP: YOU CAN USE LISTBOX.SELECTEDINDEX to GET THE INDEX OF THE SELECTED ITEM
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.