Chapter 12 Object-Oriented Programming. Starting Out with Games & Graphics in C++ Tony Gaddis

Size: px
Start display at page:

Download "Chapter 12 Object-Oriented Programming. Starting Out with Games & Graphics in C++ Tony Gaddis"

Transcription

1 Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics in C++ Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved.

2 12.1 Procedural and Object-Oriented Programming Concept: Procedural programming is a method of writing software. It is a programming practice centered on the procedures or actions that take place in a program. Object-oriented programming is centered on objects. Objects are created from abstract data types that encapsulate data and functions together. 1-2

3 12.1 Procedural and Object-Oriented Programming There are primarily two methods of programming in use today: Procedural Object oriented The programs that you have written so far have been procedural in nature. Whereas procedural programming is centered on creating functions, objectoriented programming (OOP) is centered on creating objects. An object is a software entity that contains fields and methods. Fields are simply variables, arrays, or other data structures that are stored in the object. Methods are functions that perform operations on the object's data. OOP addresses the problem of code/data separation through encapsulation and data hiding. Encapsulation refers to the combining of data and code into a single object. Data hiding refers to an object s ability to hide its fields from code that is outside the object. 1-3

4 12.1 Procedural and Object-Oriented Programming An object typically hides its fields, but allows outside code to access its methods. Only the object s methods may then directly access and make changes to the object s fields. Figure 12-2 Code outside the object interacts with the object s methods 1-4

5 12.1 Procedural and Object-Oriented Programming Object Reusability In addition to solving the problems of code/data separation, the use of OOP has also been encouraged by the trend of object reusability. An object is not a stand-alone program, but is used by programs that need its service. 1-5

6 12.1 Procedural and Object-Oriented Programming An Everyday Example of an Object Think of your alarm clock as an object It has the following fields: The current second (a value in the range of 0 59) The current minute (a value in the range of 0 59) The current hour (a value in the range of 1 12) The time the alarm is set for (a valid hour and minute) Whether the alarm is on or off ( on or off ) As you can see, the fields are merely data values that define the state that the alarm clock is currently in. 1-6

7 12.1 Procedural and Object-Oriented Programming An Everyday Example of an Object You, the user of the alarm clock object, cannot directly manipulate these fields because they are private. To change a field s value, you must use one of the object s methods Here are some of the alarm clock object s methods: Set time Set alarm time Turn alarm on Turn alarm off Each method manipulates one or more of the fields. Notice that all of these methods can be activated by you, who are outside of the alarm clock. Methods that can be accessed by entities outside the object are known as public methods. 1-7

8 12.1 Procedural and Object-Oriented Programming OOP Terminology OOP programmers commonly use the term "fields" to describe the items of data that are stored in an object, and the term "methods" to describe the procedures that operate on an object's data. C++ programmers often refer to fields as member variables Refer to methods as member functions These are the terms that we will use, since they are commonly used in C

9 Concept: A class is code that specifies the member variables and member functions for a particular type of object. 1-9

10 A class is code that specifies the member variables and member functions that a particular type of object has. Think of a class as a blueprint that objects may be created from. It serves a similar purpose as the blueprint for a house. Figure 12-3 A blueprint and houses built from the blueprint 1-10

11 A class is not an object, but a description of an object. When the program is running, it can use the class to create, in memory, as many objects of a specific type as needed. Each object that is created from a class is called an instance of the class. Figure 12-4 The cookie cutter metaphor 1-11

12 Class Declarations 1-12

13 Class Declarations 1-13

14 Mutators and Accessors Member variables are private Member functions are public A mutator function is a member function that stores or changes the member variable in some way An accessor function is a member function that gets a value from a member variable, but doesn t change it 1-14

15 Defining Member Functions Each of these functions are setting the values of the data members. There is no return value. 1-15

16 Defining Member Functions Each of these functions are getting the values of the data members and returning them to the function in which it was called 1-16

17 Defining Member Functions Uses the private data members to draw a circle 1-17

18 Creating an Object Create an instance of the Circle object 1-18

19 Constructors Establishes initial values for the data members 1-19

20 Creating Multiple Objects from the Same Class Creating three different instances of the circle class, with three different values 1-20

21 Overloaded Member Functions Two versions of the draw function, with two different parameter lists (overloaded functions) 1-21

22 Overloaded Constructors 1-22

23 Creating Arrays of Objects 1-23

24 Passing Objects as Arguments to Functions 1-24

25 Destructors 1-25

26 12.3 Inheritance Concept: Inheritance allows a new class to extend an existing class. The new class inherits the members of the class it extends. 1-26

27 12.3 Inheritance Generalization and Specialization Figure 12-2 Bumblebees and grasshoppers are specialized versions of an insect 1-27

28 12.3 Inheritance Inheritance and the Is a Relationship Inheritance involves a base class and a derived class The base class is the general class The derived class is the specialized class 1-28

29 12.3 Inheritance Inheritance and the Is a Relationship 1-29

30 12.3 Inheritance Passing Arguments to the Base Class Constructor 1-30

31 12.4 An Object-Oriented Game: Balloon Target Balloon moves repeatedly across the screen from left to right Speed randomly changes Dart positioned at the bottom of screen Player launches dart with space bar Hit the balloon with the dart as many times as possible Figure The Balloon Target Game 1-31

32 Chapter 12 Object-Oriented Programming QUESTIONS? Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved.

CS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes

CS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes CS111: PROGRAMMING LANGUAGE II Lecture 1: Introduction to classes Lecture Contents 2 What is a class? Encapsulation Class basics: Data Methods Objects Defining and using a class In Java 3 Java is an object-oriented

More information

What is an algorithm?

What is an algorithm? Reminders CS 142 Lecture 4 ADTs & Objects Program 1 was assigned - Due on 1/27 by 11:55pm Spring 2015 2 Object-Oriented Programming (OOP) OOP Definitions Imagine: You and your programming team have written

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects

More information

9/21/2010. Based on Chapter 2 in Advanced Programming Using Visual Basic.NET by Bradley and Millspaugh

9/21/2010. Based on Chapter 2 in Advanced Programming Using Visual Basic.NET by Bradley and Millspaugh Building Multitier Programs with Classes Based on Chapter 2 in Advanced Programming Using Visual Basic.NET by Bradley and Millspaugh The Object-Oriented Oriented (OOP) Development Approach Large production

More information

System Design and Programming II

System Design and Programming II System Design and Programming II CSCI 194 Section 01 CRN: 10968 Fall 2017 David L. Sylvester, Sr., Assistant Professor Chapter 13 Introduction to Classes Procedural and Object-Oriented Programming Procedural

More information

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects

More information

Chapter 11 Strings and Files. Starting Out with Games & Graphics in C++ Tony Gaddis

Chapter 11 Strings and Files. Starting Out with Games & Graphics in C++ Tony Gaddis Chapter 11 Strings and Files Starting Out with Games & Graphics in C++ Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved. 11.1 Working with Strings In C++, strings

More information

CLASSES AND OBJECTS IN JAVA

CLASSES AND OBJECTS IN JAVA Lesson 8 CLASSES AND OBJECTS IN JAVA (1) Which of the following defines attributes and methods? (a) Class (b) Object (c) Function (d) Variable (2) Which of the following keyword is used to declare Class

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 (a): Classes & Objects Lecture Contents 2 What is a class? Class definition: Data Methods Constructors objects Static members

More information

Data Structures (list, dictionary, tuples, sets, strings)

Data Structures (list, dictionary, tuples, sets, strings) Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access

More information

CS6301 PROGRAMMING AND DATA STRUCTURES II QUESTION BANK UNIT-I 2-marks ) Give some characteristics of procedure-oriented language. Emphasis is on doing things (algorithms). Larger programs are divided

More information

Dot and Scope Resolution Operator

Dot and Scope Resolution Operator Dot and Scope Resolution Operator Used to specify "of what thing" they are members Dot operator: Specifies member of particular object Scope resolution operator: Specifies what class the function definition

More information

Object-Oriented Programming Concepts

Object-Oriented Programming Concepts Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are

More information

CS1004: Intro to CS in Java, Spring 2005

CS1004: Intro to CS in Java, Spring 2005 CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a

More information

Chapter 12. OOP: Creating Object-Oriented Programs The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Chapter 12. OOP: Creating Object-Oriented Programs The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Chapter 12 OOP: Creating Object-Oriented Programs McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter Objectives - 1 Use object-oriented terminology correctly Create a two-tier

More information

Chapter 8. Operator Overloading, Friends, and References. Copyright 2010 Pearson Addison-Wesley. All rights reserved

Chapter 8. Operator Overloading, Friends, and References. Copyright 2010 Pearson Addison-Wesley. All rights reserved Chapter 8 Operator Overloading, Friends, and References Copyright 2010 Pearson Addison-Wesley. All rights reserved Learning Objectives Basic Operator Overloading Unary operators As member functions Friends

More information

Chapter 12. OOP: Creating Object- Oriented Programs. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.

Chapter 12. OOP: Creating Object- Oriented Programs. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. Chapter 12 OOP: Creating Object- Oriented Programs McGraw-Hill Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. Objectives (1 of 2) Use object-oriented terminology correctly. Create

More information

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017 Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable

More information

The Object Oriented Paradigm

The Object Oriented Paradigm The Object Oriented Paradigm Joseph Spring 7COM1023 Programming Paradigms 1 Discussion The OO Paradigm Procedural Abstraction Abstract Data Types Constructors, Methods, Accessors and Mutators Coupling

More information

Anatomy of a Class Encapsulation Anatomy of a Method

Anatomy of a Class Encapsulation Anatomy of a Method Writing Classes Writing Classes We've been using predefined classes. Now we will learn to write our own classes to define objects Chapter 4 focuses on: class definitions instance data encapsulation and

More information

Chapter 3: Modules. Starting Out with Programming Logic & Design. Second Edition. by Tony Gaddis

Chapter 3: Modules. Starting Out with Programming Logic & Design. Second Edition. by Tony Gaddis Chapter 3: Modules Starting Out with Programming Logic & Design Second Edition by Tony Gaddis Copyright 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter Topics 3.1 Introduction

More information

Object oriented programming Concepts

Object oriented programming Concepts Object oriented programming Concepts Naresh Proddaturi 09/10/2012 Naresh Proddaturi 1 Problems with Procedural language Data is accessible to all functions It views a program as a series of steps to be

More information

1. Write two major differences between Object-oriented programming and procedural programming?

1. Write two major differences between Object-oriented programming and procedural programming? 1. Write two major differences between Object-oriented programming and procedural programming? A procedural program is written as a list of instructions, telling the computer, step-by-step, what to do:

More information

Object Oriented Design: Identifying Objects

Object Oriented Design: Identifying Objects Object Oriented Design: Identifying Objects Review What did we do in the last lab? What did you learn? What classes did we use? What objects did we use? What is the difference between a class and an object?

More information

What is an algorithm?

What is an algorithm? Reminders CS 142 Lecture 3 Analysis, ADTs & Objects Program 1 was assigned - Due on 1/27 by 11:55pm 2 Abstraction Measuring Algorithm Efficiency When you utilize the mylist.index(item) function you are

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

A A B U n i v e r s i t y

A A B U n i v e r s i t y A A B U n i v e r s i t y Faculty of Computer Sciences O b j e c t O r i e n t e d P r o g r a m m i n g Week 4: Introduction to Classes and Objects Asst. Prof. Dr. M entor Hamiti mentor.hamiti@universitetiaab.com

More information

by Pearson Education, Inc. All Rights Reserved. 2

by Pearson Education, Inc. All Rights Reserved. 2 Suppose you want to drive a car and make it go faster by pressing down on its accelerator pedal. Before you can drive a car, someone has to design it and build it. A car typically begins as engineering

More information

Defining Classes and Methods

Defining Classes and Methods Defining Classes and Methods Chapter 5 Modified by James O Reilly Class and Method Definitions OOP- Object Oriented Programming Big Ideas: Group data and related functions (methods) into Objects (Encapsulation)

More information

Object Orientated Analysis and Design. Benjamin Kenwright

Object Orientated Analysis and Design. Benjamin Kenwright Notation Part 2 Object Orientated Analysis and Design Benjamin Kenwright Outline Review What do we mean by Notation and UML? Types of UML View Continue UML Diagram Types Conclusion and Discussion Summary

More information

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity. OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within

More information

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Basic 2005: Reloaded Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 10 Creating Classes and Objects Objectives After studying this chapter, you should be able to: Define a class Instantiate an object from a class

More information

Advanced Programming Using Visual Basic 2008

Advanced Programming Using Visual Basic 2008 Building Multitier Programs with Classes Advanced Programming Using Visual Basic 2008 The OOP Development Approach OOP = Object Oriented Programming Large production projects are created by teams Each

More information

Object Oriented Programming. CISC181 Introduction to Computer Science. Dr. McCoy. Lecture 27 December 8, What is a class? Extending a Hierarchy

Object Oriented Programming. CISC181 Introduction to Computer Science. Dr. McCoy. Lecture 27 December 8, What is a class? Extending a Hierarchy CISC181 Introduction to Computer Science Dr. McCoy Lecture 27 December 8, 2009 Object Oriented Programming Classes categorize entities that occur in applications. Class teacher captures commonalities of

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation Outline Problem: Create, read in and print out four sets of student grades Setting up the problem Breaking

More information

Object-Oriented Programming (OOP) Basics. CSCI 161 Introduction to Programming I

Object-Oriented Programming (OOP) Basics. CSCI 161 Introduction to Programming I Object-Oriented Programming (OOP) Basics CSCI 161 Introduction to Programming I Overview Chapter 8 in the textbook Building Java Programs, by Reges & Stepp. Review of OOP History and Terms Discussion of

More information

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Abstraction Encapsulation Inheritance and Polymorphism Object-Oriented

More information

1. A Web Form created in Visual Basic can only be displayed in Internet Explorer. True False

1. A Web Form created in Visual Basic can only be displayed in Internet Explorer. True False True / False Questions 1. A Web Form created in Visual Basic can only be displayed in Internet Explorer. 2. Windows Explorer and Internet Explorer are Web browsers. 3. Developing Web applications requires

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Chapter3: Introduction to Classes and Objects

Chapter3: Introduction to Classes and Objects Chapter3: Introduction to Classes and Objects Classes and Objects: Definitions Objectives What is an object What is a class UML representation of a class Objects and Instance variables Primitive types

More information

C++ & Object Oriented Programming Concepts The procedural programming is the standard approach used in many traditional computer languages such as BASIC, C, FORTRAN and PASCAL. The procedural programming

More information

What is a Class? Short Answer. Responding to Messages. Everything in Python is an Object 11/8/2010

What is a Class? Short Answer. Responding to Messages. Everything in Python is an Object 11/8/2010 The Practice of Computing Using PYTHON William Punch Richard Enbody Chapter 11 Introduction to Classes class Student(object): """Simple Student class.""" def init (self,first='', last='', id=0): # init

More information

A Founda4on for Programming

A Founda4on for Programming 3.1 Objects LOGO STYLE GUIDE Schools within the University Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 3/16/14 11:29 PM A Founda4on

More information

Introduction to OOP. Procedural Programming sequence of statements to solve a problem.

Introduction to OOP. Procedural Programming sequence of statements to solve a problem. Introduction to OOP C++ - hybrid language improved and extended standard C (procedural language) by adding constructs and syntax for use as an object oriented language. Object-Oriented and Procedural Programming

More information

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++

More information

Programming II. Modularity 2017/18

Programming II. Modularity 2017/18 Programming II Modularity 2017/18 Module? Lecture Outline Evolution and history of programming languages Modularity Example History of Programming Programming Paradigms How and why languages develop? How

More information

CMPT 117: Tutorial 1. Craig Thompson. 12 January 2009

CMPT 117: Tutorial 1. Craig Thompson. 12 January 2009 CMPT 117: Tutorial 1 Craig Thompson 12 January 2009 Administrivia Coding habits OOP Header Files Function Overloading Class info Tutorials Review of course material additional examples Q&A Labs Work on

More information

Chapter 4. Defining Classes I

Chapter 4. Defining Classes I Chapter 4 Defining Classes I Introduction Classes are the most important language feature that make object-oriented programming (OOP) possible Programming in Java consists of defining a number of classes

More information

Standard. Number of Correlations

Standard. Number of Correlations Computer Science 2016 This assessment contains 80 items, but only 80 are used at one time. Programming and Software Development Number of Correlations Standard Type Standard 2 Duty 1) CONTENT STANDARD

More information

7. C++ Class and Object

7. C++ Class and Object 7. C++ Class and Object 7.1 Class: The classes are the most important feature of C++ that leads to Object Oriented programming. Class is a user defined data type, which holds its own data members and member

More information

COURSE OUTLINE. Faculty of Computing, Universiti Teknologi Malaysia

COURSE OUTLINE. Faculty of Computing, Universiti Teknologi Malaysia Page : 1 of 5 Lecturer : Dr. Norsham binti Idris Room No. : Software Engineering Department, Telephone No. : 07-5532348/013-7261920 E-mail : norsham@utm.my Course Synopsis : This course presents the concepts

More information

Introduction to Classes

Introduction to Classes Introduction to Classes Procedural and Object-Oriented Programming Procedural and Object-Oriented Programming Procedural programming focuses on the process/actions that occur in a program Object-Oriented

More information

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects CmSc 150 Fundamentals of Computing I Lesson 28: Introduction to Classes and Objects in Java 1. Classes and Objects True object-oriented programming is based on defining classes that represent objects with

More information

VB.NET. Exercise 1: Creating Your First Application in Visual Basic.NET

VB.NET. Exercise 1: Creating Your First Application in Visual Basic.NET VB.NET Module 1: Getting Started This module introduces Visual Basic.NET and explains how it fits into the.net platform. It explains how to use the programming tools in Microsoft Visual Studio.NET and

More information

Chapter 11: Inheritance

Chapter 11: Inheritance Chapter 11: Inheritance Starting Out with Java: From Control Structures through Objects Fourth Edition by Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved. Reading

More information

Objects and Classes. Basic OO Principles. Classes in Java. Mark Allen Weiss Copyright 2000

Objects and Classes. Basic OO Principles. Classes in Java. Mark Allen Weiss Copyright 2000 Objects and Classes Mark Allen Weiss Copyright 2000 8/30/00 1 Basic OO Principles Objects are entities that have structure and state. Each object defines operations that may access or manipulate that state.

More information

(12-1) OOP: Polymorphism in C++ D & D Chapter 12. Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University

(12-1) OOP: Polymorphism in C++ D & D Chapter 12. Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University (12-1) OOP: Polymorphism in C++ D & D Chapter 12 Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University Key Concepts Polymorphism virtual functions Virtual function tables

More information

Chapter 7. Inheritance

Chapter 7. Inheritance Chapter 7 Inheritance Introduction to Inheritance Inheritance is one of the main techniques of objectoriented programming (OOP) Using this technique, a very general form of a class is first defined and

More information

JAVA: A Primer. By: Amrita Rajagopal

JAVA: A Primer. By: Amrita Rajagopal JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently

More information

Data Structures using OOP C++ Lecture 3

Data Structures using OOP C++ Lecture 3 References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

JAVA MOCK TEST JAVA MOCK TEST II

JAVA MOCK TEST JAVA MOCK TEST II http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your

More information

Lesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014

Lesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014 Lesson 10B Class Design By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Encapsulation Inheritance and Composition is a vs has a Polymorphism Information Hiding Public

More information

Ch02. True/False Indicate whether the statement is true or false.

Ch02. True/False Indicate whether the statement is true or false. Ch02 True/False Indicate whether the statement is true or false. 1. The base class inherits all its properties from the derived class. 2. Inheritance is an is-a relationship. 3. In single inheritance,

More information

Chapter 5: Methods. by Tony Gaddis. Starting Out with Java: From Control Structures through Objects. Fourth Edition

Chapter 5: Methods. by Tony Gaddis. Starting Out with Java: From Control Structures through Objects. Fourth Edition Chapter 5: Methods Starting Out with Java: From Control Structures through Objects Fourth Edition by Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved. Reading

More information

Object Oriented Programming COP3330 / CGS5409

Object Oriented Programming COP3330 / CGS5409 Object Oriented Programming COP3330 / CGS5409 Classes & Objects DDU Design Constructors Member Functions & Data Friends and member functions Const modifier Destructors Object -- an encapsulation of data

More information

Chapter 5 Object-Oriented Programming

Chapter 5 Object-Oriented Programming Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares

More information

C++ Review. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

C++ Review. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University C++ Review CptS 223 Advanced Data Structures Larry Holder School of Electrical Engineering and Computer Science Washington State University 1 Purpose of Review Review some basic C++ Familiarize us with

More information

Defining Classes and Methods. Objectives. Objectives 6/27/2014. Chapter 5

Defining Classes and Methods. Objectives. Objectives 6/27/2014. Chapter 5 Defining Classes and Methods Chapter 5 Objectives Describe concepts of class, class object Create class objects Define a Java class, its methods Describe use of parameters in a method Use modifiers public,

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 Learn about class concepts How to create a class from which objects can be instantiated Learn about instance variables and methods How to declare objects How to organize your classes Learn about public

More information

I Wish I Knew How To. Begin Object Oriented Programming With Xojo. By Eugene Dakin. July 2015 Edition (1.0)

I Wish I Knew How To. Begin Object Oriented Programming With Xojo. By Eugene Dakin. July 2015 Edition (1.0) I Wish I Knew How To Begin Object Oriented Programming With Xojo July Edition (1.0) By Eugene Dakin Table of Contents Chapter 1 - Introduction to Object Oriented Programming... 6 Being the Architect...

More information

Fundamental Concepts

Fundamental Concepts Object Oriented Testing For System Testers Chapter 2 Fundamental Concepts 2-1 Chapter Objectives At the end of this chapter you will be able to define and use the following concepts: - Object - Class -

More information

CHAPTER 5 GENERAL OOP CONCEPTS

CHAPTER 5 GENERAL OOP CONCEPTS CHAPTER 5 GENERAL OOP CONCEPTS EVOLUTION OF SOFTWARE A PROGRAMMING LANGUAGE SHOULD SERVE 2 RELATED PURPOSES : 1. It should provide a vehicle for programmer to specify actions to be executed. 2. It should

More information

Topic 10: Introduction to OO analysis and design

Topic 10: Introduction to OO analysis and design Topic 10: Introduction to OO analysis and design Learning Outcomes Upon successful completion of this topic you will be able to: design classes define class member variables and functions explain public

More information

Advantages of Object Oriented Programming :- Features of Object Oriented Programming :- Advantages Of Object Oriented Programming :

Advantages of Object Oriented Programming :- Features of Object Oriented Programming :- Advantages Of Object Oriented Programming : Advantages of Object Oriented Programming :- 1. Exploits the expressive power of all object oriented programming languages. 2. Encourages the resuse of software components. 3. Leads to the systems that

More information

Defining Classes and Methods

Defining Classes and Methods Walter Savitch Frank M. Carrano Defining Classes and Methods Chapter 5 ISBN 0136091113 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Objectives Describe concepts of class, class

More information

Topics. Topics (Continued) 7.1 Abstract Data Types. Abstraction and Data Types. 7.2 Object-Oriented Programming

Topics. Topics (Continued) 7.1 Abstract Data Types. Abstraction and Data Types. 7.2 Object-Oriented Programming Chapter 7: Introduction to Classes and Objects Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Topics 7.1 Abstract Data Types 7.2 Object-Oriented Programming

More information

Computing Science. Advanced Higher Programming. Project 1 - Balloon Burst. Version 1. Software Design and Development. (using Python and Pygame)

Computing Science. Advanced Higher Programming. Project 1 - Balloon Burst. Version 1. Software Design and Development. (using Python and Pygame) Computing Science Software Design and Development Advanced Higher 2015 Programming (using Python and Pygame) Project 1 - Balloon Burst Version 1 G. Reid, D. Stott, Contents Page 1 Page 3 Page 4 Page 5

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Lecture 5: Object Oriented Programming Autumn 2011-12 1 Lecture 4 Highlights Tuples, Dictionaries Sorting Lists Modular programming Data analysis: text categorization

More information

Lecture 18 Tao Wang 1

Lecture 18 Tao Wang 1 Lecture 18 Tao Wang 1 Abstract Data Types in C++ (Classes) A procedural program consists of one or more algorithms that have been written in computerreadable language Input and display of program output

More information

CSE 401/M501 Compilers

CSE 401/M501 Compilers CSE 401/M501 Compilers ASTs, Modularity, and the Visitor Pattern Hal Perkins Autumn 2018 UW CSE 401/M501 Autumn 2018 H-1 Agenda Today: AST operations: modularity and encapsulation Visitor pattern: basic

More information

Outline. Outline. 1 Chapter 2: Data Abstraction

Outline. Outline. 1 Chapter 2: Data Abstraction Outline Outline 1 Chapter 2: Data Abstraction From Data Type to ADT Values A value is a unit of information used in a program. It can be associated with a constant or variable (a name) by an assignment

More information

Babaria Institute of Technology Computer Science and Engineering Department Practical List of Object Oriented Programming with C

Babaria Institute of Technology Computer Science and Engineering Department Practical List of Object Oriented Programming with C Practical -1 Babaria Institute of Technology LEARN CONCEPTS OF OOP 1. Explain Object Oriented Paradigm with figure. 2. Explain basic Concepts of OOP with example a. Class b. Object c. Data Encapsulation

More information

Chapter 6 Structures and Classes. GEDB030 Computer Programming for Engineers Fall 2017 Euiseong Seo

Chapter 6 Structures and Classes. GEDB030 Computer Programming for Engineers Fall 2017 Euiseong Seo Chapter 6 Structures and Classes 1 Learning Objectives Structures Structure types Structures as function arguments Initializing structures Classes Defining, member functions Public and private members

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

CMSC 202H. Classes and Objects: Reusing Classes with Composition

CMSC 202H. Classes and Objects: Reusing Classes with Composition CMSC 202H Classes and Objects: Reusing Classes with Composition Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing it

More information

Review and Recursion

Review and Recursion Midterm Exam Review Division of Mathematics and Computer Science Maryville College Outline Midterm Exam Review 1 Midterm Exam Review 2 Questions 1-10 Midterm Exam Review 1 What are some of the main challenges

More information

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes Based on Introduction to Java Programming, Y. Daniel Liang, Brief Version, 10/E 1 Creating Classes and Objects Classes give us a way of defining custom data types and associating data with operations on

More information

OUTCOMES BASED LEARNING MATRIX

OUTCOMES BASED LEARNING MATRIX OUTCOMES BASED LEARNING MATRIX Course: CTIM 372 Advanced Programming in C++ Department: Computer Technology and Information Management 3 credits/4 contact hours Description: This course is a continuation

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming 1/9 Introduction to Object-Oriented Programming Conception et programmation orientées object, B. Meyer, Eyrolles Object-Oriented Software Engineering, T. C. Lethbridge, R. Laganière, McGraw Hill Design

More information

Compaq Interview Questions And Answers

Compaq Interview Questions And Answers Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not

More information

CS200: Advanced OO in Java

CS200: Advanced OO in Java Object Oriented Programming CS200: Advanced OO in Java n Programming paradigm using Objects : data structures consisting of data fields and methods together with their interaction. n Object? n Class? n

More information

Chapter 2: Input, Processing, and Output

Chapter 2: Input, Processing, and Output Chapter 2: Input, Processing, and Output Starting Out with Programming Logic & Design Second Edition by Tony Gaddis Copyright 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter Topics

More information

C#.NET TRAINING / /

C#.NET TRAINING / / C#.NET TRAINING.NET ENTERPRISE ARCHITECTURE Introduction to the.net platform Common Language Run Time(CLR) The Common Type Specification(CTS) The Common Language Specification(CLS) Microsoft Intermediate

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 Learn about class concepts How to create a class from which objects can be instantiated Learn about instance variables and methods How to declare objects How to organize your classes Learn about public

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College August 29, 2018 Outline Outline 1 Chapter 2: Data Abstraction Outline Chapter 2: Data Abstraction 1 Chapter 2: Data Abstraction

More information

Principles of Object Oriented Programming. Lecture 4

Principles of Object Oriented Programming. Lecture 4 Principles of Object Oriented Programming Lecture 4 Object-Oriented Programming There are several concepts underlying OOP: Abstract Types (Classes) Encapsulation (or Information Hiding) Polymorphism Inheritance

More information