8-1 Chapter 8 Using User-Defined Data Types and Object Oriented Programming.

Slides:



Advertisements
Similar presentations
Chapter 51 Products, Processes, and Quality Chapter 5 Achieving Quality Through Continual Improvement Claude W. Burrill / Johannes Ledolter Published.
Advertisements

Chapter 15 Creating Database Forms and Reports Introduction Forms Reports.
Chapter 5: Database Forms and Reports
Chapter 181 Managing by Facts Chapter 18 Achieving Quality Through Continual Improvement Claude W. Burrill / Johannes Ledolter Published by John Wiley.
© Copyright 2011 John Wiley & Sons, Inc.
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.
Chapter 101 Information Technology For Management 6 th Edition Turban, Leidner, McLean, Wetherbe Lecture Slides by L. Beaubien, Providence College John.
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.
Managerial Accounting by James Jiambalvo
Systems Analysis and Design
Lesson 11: Maximizing Site Design Introduction to Adobe Dreamweaver CS6 Adobe Certified Associate: Web Communication using Adobe Dreamweaver CS6.
4-1 Coding Complete COBOL Programs: The PROCEDURE DIVISION Chapter 4.
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
3-1 Chapter 3 Variables, Assignment Statements, and Arithmetic.
10-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Introduction to Databases Chapter 7: Data Access and Manipulation.
“Copyright © 2001 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 10: Class and Method.
Accounting Principles, Ninth Edition
Slide 1 UML Review Chapter 2: Introduction to Object-Oriented Systems Analysis and Design with the Unified Modeling Language, Version 2.0 Alan Dennis,
Today’s Agenda  Any questions about the assignment (due Mon)?  Quiz  Quiz review  Homework for Friday:  Watch the two videos on the Coursera db website.
15-1 Chapter 15 Building Communities Applying Innovation By David O’Sullivan and Lawrence Dooley © Sage Publications 2008.
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.
5-1 Chapter 5 The Repetition Process in VB.NET. 5-2 Learning Objectives Understand the importance of the repetition process in programming. Describe the.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Wixom, and David Tegarden Chapter 8: Behavioral Modeling.
13-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Chapter 111 Information Technology For Management 6 th Edition Turban, Leidner, McLean, Wetherbe Lecture Slides by L. Beaubien, Providence College John.
Copyright © 2000 John Wiley & Sons, Inc. All rights reserved
9-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
“Copyright © 2001 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976.
PowerPoint Presentation for Dennis & Haley Wixom, Systems Analysis and Design, 2 nd Edition Copyright 2003 © John Wiley & Sons, Inc. All rights reserved.
PowerPoint Presentation for Dennis & Haley Wixom, Systems Analysis and Design, 2 nd Edition Copyright 2003 © John Wiley & Sons, Inc. All rights reserved.
Slide 1-1 Chapter 1 Terms Information Systems Overview Introduction to Information Systems Judith C. Simon.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 10: Class and Method.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Wixom, and David Tegarden Chapter 8: Behavioral Modeling.
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
INVESTMENTS: Analysis and Management Second Canadian Edition INVESTMENTS: Analysis and Management Second Canadian Edition W. Sean Cleary Charles P. Jones.
Copyright © 2000 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976.
4-1 Chapter 4 The Selection Process in VB.NET. 4-2 Learning Objectives Understand the importance of the selection process in programming. Describe the.
6-1 Chapter 6 Working with Arrays in VB.NET. 6-2 Learning Objectives Understand the use of list and table arrays in VB.NET projects and the difference.
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
Copyright © 2000 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976.
Copyright 2006 John Wiley & Sons, Inc. Beni Asllani University of Tennessee at Chattanooga Operations Management - 5 th Edition Chapter 10 Supplement Roberta.
Slide 8-1 Chapter 8 Terms Programming Languages Introduction to Information Systems Judith C. Simon.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Wixom, and David Tegarden Chapter 8: Behavioral Modeling.
A- 1. A- 2 Appendix B Standards of Ethical Conduct for Management Accountants The Institute of Management Accountants has published and promoted the following.
K-1. K-2 Appendix K Standards of Ethical Conduct for Management Accountants The Institute of Management Accountants has published and promoted the following.
Copyright © 2000 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976.
Slide 11-1 Chapter 11 Terms Information Resource Management Strategies Introduction to Information Systems Judith C. Simon.
Chapter 7-1. Chapter 7-2 CHAPTER 7 ACCOUNTING INFORMATION SYSTEMS Accounting Principles, Eighth Edition.
Introduction to Business Information Systems by Mark Huber, Craig Piercy, Patrick McKeown, and James Norrie Tech Guide D: The Details of SQL, Data Modelling,
I-1. I-2 I ACCOUNTING FOR SOLE PROPRIETORSHIPS Accounting, Fifth Edition.
H-1 Prepared by Coby Harmon University of California, Santa Barbara Westmont College.
2-1 Chapter 2 Using VB.NET to Create a First Solution.
“Copyright © 2001 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976.
Roberta Roth, Alan Dennis, and Barbara Haley Wixom
Systems Analysis and Design with UML Version 2.0, Second Edition
Systems Analysis and Design
Systems Analysis and Design With UML 2
An Introduction to Programming and VB.NET
Appendix Sample Innovation Plan
Transportation and Transshipment Models
Systems Analysis and Design
ACCOUNTING INFORMATION SYSTEMS
Systems Analysis and Design with UML Version 2.0, Second Edition
Presentation transcript:

8-1 Chapter 8 Using User-Defined Data Types and Object Oriented Programming

8-2 Learning Objectives Understand User-defined Data Types (UDTs) and their Relationship to Object Oriented Programming (OOP). Create and use your own UDTs. Understand and discuss the basic concepts of Object Oriented Programming.

8-3 Learning Objectives (continued) Describe the basics of the.Net framework and namespaces. Work with ArrayLists and HashTables Create and use your own object classes.

8-4 User Defined Data Types User defined data types (UDT’s) allows you to group together values of different types into a single variable Ex: Imagine a Person data type that would contain a String to hold the first name, another string to hold the last name and an integer to hold the age

8-5 UDT Example Structure Person Dim LastName As String Dim FirstName As String Dim Age As Integer End Structure ‘Declare a variable of type Person Dim Jack As Person ‘Assign values to each element Jack.LastName = “Woods” Jack.FirstName = “James” Jack.Age = 50

8-6 UDT Example continued ‘Declare another Person variable Dim Joe as Person ‘Assign one Person variable to another one Joe = Jack ‘This will display “James Woods” because the ‘assignment is done element by element MsgBox(Joe.FirstName & “ “ & Joe.LastName)

8-7 The With Statement Use With … End With syntax to avoid repeating the variable every time you access a element of it With Joe MsgBox(“FirstName: “ &.FirstName) MsgBox(“LastName: “ &.LastName) MsgBox(“Age: “ &.Age) End with

8-8 More details about UDT’s UDT’s can contain procedures – Sub’s and/or Function’s You can create arrays of UDT’s – Dim Crowd() As Person ‘ an array of persons Individual elements of UDT’s can be UDT’s Structure MarriedCouple Dim Him As Person Dim Her As Person Dim Chidren() As Person End Structure

8-9 Step-by-step 8-1: Working with UDTs Demo

8-10 Sorting an Array of User Defined Types The algorithm is the same as for simple types Needed – Comparison: will depend on the UDT’s – Swap: same as for simple types

8-11 Sorting Employees() Sub procedure to sort the Employees array Sub SortEmp() Dim Counter, NextToLast As Integer Dim NotSwitched As Boolean, Temp As EmpRecord NotSwitched = False Do Until NotSwitched NotSwitched = True For Counter = 0 To EmpCntr - 1 If Employees(Counter). LName > Employees(intCounter + 1).LName Then Temp = Employees(intCounter) Employees(Counter) = Employees(Counter + 1) Employees(Counter + 1) = Temp NotSwitched = False End If Next Loop End Sub

8-12 Step-by-step 8-2: Vintage DVDs Payroll Demo

8-13 Step-by-step 8-3: The Employee Information Form Demo

8-14 Object Oriented Programming Object: a self-contained module that can combine data and program code and that cooperates in the program by passing strictly defined messages to one another. Objects have – Properties (characteristics, information, nouns) – Methods (capabilities, actions, verbs) – Events (notification messages)

8-15 The Class: Blueprint for objects To create object in code, you first need a Class module The class is the cookie cutter, the object is the cookie An object is an instance of a Class, i.e. created according to the blueprint provided by the Class

8-16 Example of a Class

8-17 Example of an Instance, an Object

8-18 Pillars of Object Oriented Programming Encapsulation – If you know a class or object provides a certain functionality, you don’t need to know how it does it – An object is a black box Inheritance – Allows to specialize a class, (adding more properties or methods) without having to modify base class or rewrite code that is the same Polymorphism – Ability to interact with different classes in similar way. Ask a dog to walk, ask a cow to walk. Different classes, same message

8-19 Inheritance

8-20 Polymorphism

8-21 Namespaces Hierarchical naming scheme.Net Framework Class Library contains many classes – System – System.IO – System.Windows – System.Windows.Forms

8-22 More on namespaces To avoid having to write the full name of a class, (including namespace) you can “import” a namespace by using the Imports keyword – Imports System.Windows.Forms – This must be put at the top of a module outside all class code You create you own namespace when you create a project, it is the “root namespace” for your code

8-23 Collection types of Classes The Collection namespace contains many classes with specific uses ArrayList – allows you to create objects that act like smart arrays – Easy to resize HashTable – Similar to ArrayList, but you give each element that you store a unique name. – Easy to search

8-24 ArrayList Properties

8-25 ArrayList Methods

8-26 Step-by-Step 8-4: Declaring and using Objects Demo

8-27 Creating a Class 1. Add a Class module to the project. 2. Declare local variables to be used in the module. 3. Initialize the Class properties of the object by creating a constructor. 4. Write the statements necessary to enable the class to have values assigned to its properties or to assign its properties to variables outside of the object. 5. Write the methods that will carry out processing within the class. 6. Save the class module

8-28 A Class Example: A Two-Dimensional Vector Begin Class Vector2D Private mX as Double Private mY as Double Public Property X() As Double Get Return mX End Get Set(ByVal Value As Double) mX = Value End Set End Property : End Class

8-29 Two Constructors Public Sub New() mX = 0.0 mY = 0.0 End Sub Public Sub New( x As Double, y As Double) mX = x mY = y End Sub

8-30 A Method Public Function Add( v As Vector2D ) As Vector2D Dim vTemp as New Vector2D(0,0) vTemp.X = mX + v.X vTemp.Y = mY + v.Y Return vTemp End Function

8-31 Step-by-step 8-5: Creating a Class and Objects Demo

8-32 Copyright 2004 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in section 117 of the 1976 United States Copyright Act without express permission of the copyright owner is unlawful. Request for further information should be addressed to the Permissions Department, John Wiley & Sons, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages caused by the use of these programs or from the use of the information herein