CS148 Introduction to Programming II

Slides:



Advertisements
Similar presentations
Chapter 6 Structures and Classes. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 6-2 Learning Objectives Structures Structure types Structures.
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
C++ Classes & Data Abstraction
Lecture 18: 4/11/2003CS148 Spring CS148 Introduction to Programming II Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Wednesday, 10/2/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/2/02  QUESTIONS (on HW02 – due at 5 pm)??  Today:  Review of parameters  Introduction.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Lecture 29 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
Chapter 11: Classes and Data Abstraction
1 Abstract Data Type (ADT) a data type whose properties (domain and operations) are specified (what) independently of any particular implementation (how)
SEN 909 OO Programming in C++ Final Exam Multiple choice, True/False and some minimal programming will be required.
CHAPTER 13 CLASSES AND DATA ABSTRACTION. In this chapter, you will:  Learn about classes  Learn about private, protected, and public members of a class.
Data Structures Using C++1 Chapter 1 -Software Engineering Principles -ADT and Classes.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
1 Chapter Structured Types, Data Abstraction and Classes Dale/Weems.
Design.ppt1 Top-down designs: 1. Define the Problem IPO 2. Identify tasks, Modularize 3. Use structure chart 4. Pseudocode for Mainline 5. Construct pseudocode.
CS 210 DATA STRUCTURES AND ALGORITHIMS Fall 2006.
Classes Structured Programming 256 Chapter 8 Classes - Part I OOP & Class Object Terminology File Management.
Views of Data Data – nouns of programming world the objects that are manipulated information that is processed Humans like to group information Classes,
CS Introduction to Data Structures Spring Term 2004 Franz Hiergeist.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
EGR 2261 Unit 11 Classes and Data Abstraction  Read Malik, Chapter 10.  Homework #11 and Lab #11 due next week.  Quiz next week.
1 Final Exam Tues 3/16/10 (2-3:50) (Same classroom) Old Textbook - Chapters 11-16, 18 Focus is on 15, 16 and 18 Final Exam Tues 3/16/10 (2-3:50) (Same.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Lecture 10: 2/17/2003CS148 Spring CS148 Introduction to Programming II Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 12: Classes and Data Abstraction.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
1 Data Structures CSCI 132, Spring 2014 Lecture 2 Classes and Abstract Data Types Read Ch Read Style Guide (see course webpage)
Lecture 17: 4/4/2003CS148 Spring CS148 Introduction to Programming II Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
CSIS 123A Lecture 1 Intro To Classes Glenn Stevenson CSIS 113A MSJC.
Data Structures Lecture 4: Classes in C++ Azhar Maqsood NUST Institute of Information Technology (NIIT)
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
1 Chapter 12 Classes and Abstraction. 2 Chapter 12 Topics Meaning of an Abstract Data Type Declaring and Using a class Data Type Using Separate Specification.
Advanced Data Structures Lecture 1
Chapter 12 Classes and Abstraction
Structures and Classes
chapter 11 Structured Types, Data Abstraction, and Classes
Dale/Weems/Headington
Java Programming: Guided Learning with Early Objects
Polymorphism.
Review: Two Programming Paradigms
About the Presentations
Chapter Structured Types, Data Abstraction and Classes
Section 11.1 Class Variables and Methods
User-Defined Classes and ADTs
Introduction to Structured Data Types and Classes
CS212: Object Oriented Analysis and Design
Classes and Data Abstraction
CS170 Computer Organization and Architecture I
Chapter 9 Objects and Classes
CS148 Introduction to Programming II
CS148 Introduction to Programming II
COP 3330 Object-oriented Programming in C++
CS149D Elements of Computer Science
CS148 Introduction to Programming II
CS148 Introduction to Programming II
Chapter 9 Introduction To Classes
Data Structures and ADTs
Oriented Design and Abstract Data Type
Separating Interface from Implementation
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
CS148 Introduction to Programming II
CS148 Introduction to Programming II
CS148 Introduction to Programming II
CS148 Introduction to Programming II
Presentation transcript:

CS148 Introduction to Programming II Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 14: 3/17/2003 Lecture 14: 3/17/2003 CS148 Spring 2003

Outline Abstract Data Types Introduction to C++ Classes Lecture 14: 3/17/2003 CS148 Spring 2003

Abstract Data Types 1/3 Abstraction Control abstraction The act of separating the essential qualities of an object from the details of how it works or how it is composed Control abstraction Separation of logical properties of an action from its implementation When we invoke a library function, we use the function specification, without knowing the details of the function’s implementation, e.g., sqrt function in math library Data Abstraction Every data type consists of a set of values along with a collection of allowable operations on those values Lecture 14: 3/17/2003 CS148 Spring 2003

Abstract Data Types 2/3 Data abstraction comes into play when we declare a data type that is not built into the programming language The new data type can be defined as an Abstract Data Type (ADT) An ADT is a data type whose properties (domain and operations) are specified independently of any particular implementation An ADT has a specification (What?) and an implementation (How?) The specification describes the characteristics of the data values as well as the behavior of each of the operations on those values The user of an ADT needs to understand only the specification, not the implementation in order to use it Lecture 14: 3/17/2003 CS148 Spring 2003

Abstract Data Types 3/3 An ADT for representing Time TYPE OPERATIONS DOMAIN Each TimeType value if a time of day in the form of hours, minutes, and seconds OPERATIONS Set the time Print the time Increment the time by one second Compare two times for equality Determine if one time comes before another Lecture 14: 3/17/2003 CS148 Spring 2003

C++ Classes 1/3 C++ supports representing ADTs by providing a built-in structured type known as class Four structured data types available in C++: Array, struct, union, and class A class is similar to a struct but its components (class members) include not only data, but also functions that manipulate that data A C++ class declaration corresponding to TimeType ADT class TimeType { public: void set (int, int, int); void Increment(); void Write(); bool Equal (TimeType); bool LessThan (TimeType); private: int hrs; int mins; int secs; }; TYPE: TimeType DOMAIN: Each TimeType value if a time of day in the form of hours, minutes, and seconds OPERATIONS Set the time Print the time Increment the time by one second Compare two times for equality Determine if one time comes before another Lecture 14: 3/17/2003 CS148 Spring 2003

C++ Classes 2/3 The declaration of a class defines a data type but does not create variables of the type (a class variable is called a class object or class instance) Class objects created using variable declarations TimeType startTime; Any software that declares and manipulates TimeType objects is called a client of the class Data and/or functions declared as public constitute the public interface, which means clients can access these class members directly Class members declared as private are considered as private information and are inaccessible to clients. In C++, class members are by default private Built-in operations on classes: member selection and assignment startTime.Increment(); //using dot notation Lecture 14: 3/17/2003 CS148 Spring 2003

C++ Classes 3/3 TimeType time1; TimeType time2; int inputHrs,inputMins,inputSecs; time1.Set(5,20,0); cin >> inputHrs >>inputMins >>inputSecs; time2.Set(inputHrs,inputMins,inputSecs); if (time1.LessThan(time2)) … time2 = time1; time2.Write(); class TimeType { public: void set (int, int, int); void Increment(); void Write(); bool Equal (TimeType); bool LessThan (TimeType); private: int hrs; int mins; int secs; }; Lecture 14: 3/17/2003 CS148 Spring 2003