9618 Computer Science
AS Content
Chpater 1 Information representation
1.1 Data representation
1.2 Multimedia
1.3 Compression
Chapter 2 Communication
2.1 Networking
2.2 The internet
Chpater 3 Hardware
3.1 Computers and their components
3.2 Logic Gates and Logic Circuits
Chapter 4 Processor Fundamentals
4.1 Central Processing Unit (CPU) Architecture
4.2 Assembly Language
4.3 Bit manipulation
Chapter 5 System Software
5.1 Operating Systems
5.2 Language Translators
Chapter 6 Security, privacy and data integrity
6.1 Data Security
6.2 Data Integrity
Chpater 7 Ethics and Ownership
7.1 Ethics and Ownership
Chapter 8 Databases
8.1 Database Concepts
8.2 Database Management Systems (DBMS)
8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)
Chapter 9 Algorithm Design and Problem-solving
9.1 Computational Thinking Skills
9.2 Algorithms
Chapter 10 Data Types and Records
10.1 Data Types and Records
10.2 Arrays
10.3 Files
10.4 Introduction to Abstract Data Types (ADT)
Chapter 11 Programming
11.1 Programming Basics
11.2 Constructs
11.3 Structured Programming
Chapter 12 Software Development
12.1 Program Development Life cycle
12.2 Program Design
12.3 Program Testing and Maintenance
A2 Content
Chapter 13 Data Representation
13.1 User-defined data types
13.2 File organisation and access
13.3 Floating-point numbers, representation and manipulation
Chpater 14 Communication and internet technologies
14.1 Protocols
14.2 Circuit switching, packet switching
Chpater 15 Hardware
15.1 Processors, Parallel Processing and Virtual Machines
15.2 Boolean Algebra and Logic Circuits
Chapter 16 Operating System
16.1 Purposes of an Operating System (OS)
16.2 Translation Software
Chpater 17 Security
17.1 Encryption, Encryption Protocols and Digital certificates
Chpater 18 Artificial intelligence (AI)
18.1 Artificial Intelligence (AI)
Chapter 19 Computational thinking and problem solving
19.1 Algorithms
19.2 Recursion
Chapter 20 Further programming
20.1 Programming Paradigms
20.2 File Processing and Exception Handling
Mr. Theo
-
+
首页
13.1 User-defined data types
# User-Defined Data Types ##### the purpose of a user-defined data type - To create a new data type (from existing data types) - To allow data types not available in a programming language to be constructed // To extend the flexibility of the programming language ## Composite data types #### What is meant by composite data types - A (user defined) data type that is a collection of data that can consist of multiple elements - of different or the same data types - grouped under a single identifier. #### What is meant by a user-defined composite data type - A data type constructed by a programmer // not a primitive data type - A data type that references at least one other data type… - … the data types can be primitive, or user defined ##### example Class / object / set / Record ### Record Data type - *Allow programmer to create record data type with components that precisely match the data requirements of the particular program ```pseudocode TYPE <main identifier> DECLARE <subidentifier1> : <built in data type> DECLARE <subidentifier2> : <built in data type> ENDTYPE // Creating a variable using this record data-type. DECLARE myVariable : main identifier // The variable is declared as a record <main identifier>.<sub identifier(x)> ← <value> ``` Example ```pseudocode TYPE TEmployeeRecord DECLARE FirstName : STRING DECLARE LastName : STRING DECLARE Salary$ : REAL DECLARE Position : STRING ENDTYPE DECLARE Employee1 : TStudentRecord Employee1.FirstName ← "John" Employee1.LastName ← "Doe" Employee1.Salary$ ← 2830.80 Employee1.Position ← "Project Manager" ``` ### Set Data type - Allows a program to create sets and to apply the mathematical operations defined in set theory - A set is mathematical concept with important properties - Contains a collection of data values - No organisation of the data value within the set - Duplicate values are not allowed ```pseudocode // In pseudocode the type definition has this structure: TYPE <set-identifier> = SET OF <Basetype> // Variable definition DEFINE <identifier> (value1, value2, value3, ... ) : <set-identifier> ``` Example ```pseudocode TYPE Days = SET OF STRING DEFINE Today (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday) : Days ``` #### Objects and Classes - Is a data type which is used is used for an object-oriented programming - There are likely to be a number of built in classes ## Non-Composite data types ### What is meant by non-composite data types - It can be defined without referencing another data type - It can be a primitive type available in a programming language, **or** a user- defined type. ##### Enumerated data type - A user-defined non-composite (data type) - …with a list of all possible values - …that is ordered. ```pseudocode TYPE <Datatype> = (<value1>,<value2>,<value3>…) DECLARE <identifier> : <datatype> ``` Example ```pseudocode TYPE Season = (Summer,Winter,Autumn,Spring) // Note: we are not writing Summer intead of "Summer" b/c it is a non-composite data type DECLARE ThisSeason : Season DECLARE NextSeason : Season ThisSeason <-- Autum NextSeason <-- ThisSeason + 1 // NextSeason is set to Spring ``` ##### Pointer data type - A user-defined non-composite (data type) (only award once) - …that stores addresses/memory locations only - …and indicates the type of data stored in the memory location. ```pseudocode TYPE <Datatype> = ^<type name> // Declaring a pointer variable DECLARE <identifier> : <datatype> <assignment value> ← <identifier>^ // This accesses the data stored at the address which IntegerPointer points to. This is known as dereferencing. ``` Example: ```pseudocode SecondPointer <-- @<identifier> //This stores the memory address of the <identifier> in SecondPointer SecondPointer^ <-- MyVariable //This stores the value in MyVariable to the memory location currently pointed by SecondPointer. ```  Use the diagram to state the current values of the following expressions. IPointer: 4402 // This is the address that IPointer is pointing to. IPointer^: 33 //This is the value stored at the address (4402) the IPointer is pointing to. @MyInt1: 3427 //This is the address of MyInt1 IPointer^ = MyInt2 : TRUE //This compares the value of MyInt2 to the value stored at the address (4402) **Write pseudocode statements that will achieve the following.** 1. **Place the address of MyInt2 in the IPointer.** ```pseudocode IPointer <-- @MyInt2 ``` 2. **Assign the value 33 to the variable MyInt1.** ```pseudocode MyInt1<-- 33 ``` 3. **Copy the value of MyInt2 into the memory location currently pointed at by the IPointer.** ```pseudocode IPointer^ <-- MyInt2 ``` Example Questions: The value for *NumberOfCopies* must be between *1* *and* *10* inclusive. ```pseudocode DECLARE NumberOfCopies : 1 .. 10 ``` The values for *BicycleID* *must be between* *500* *and* *599* inclusive. ```pseudocode DECLARE BicycleID : 500 .. 599 ```
Theo
2025年5月30日 13:35
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
Word文件
PDF文档
PDF文档(打印)
分享
链接
类型
密码
更新密码
有效期