Chapter 11-12 More on Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Object Oriented Programming A brief review of what you should know about OOP.
Classes and Objects April 6, Object Oriented Programming Creating functions helps to make code that we can reuse. When programs get large it becomes.
Creating Object Oriented Programs Object oriented (OO) terminology Class vs. object Instantiate an object in a project Understand Class_Initialize / Terminate.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Inheritance and Polymorphism CS351 – Programming Paradigms.
1 Using Classes Object-Oriented Programming Using C++ Second Edition 5.
Using Classes Object-Oriented Programming Using C++ Second Edition 5.
Introduction to Object-oriented programming and software development Lecture 1.
© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.
An Object-Oriented Approach to Programming Logic and Design
Chapter 11 Introduction to Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Chapter 11 Introduction to Classes. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. Code Listing 11.1.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Classes Structured Programming 256 Chapter 8 Classes - Part I OOP & Class Object Terminology File Management.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Views of Data Data – nouns of programming world the objects that are manipulated information that is processed Humans like to group information Classes,
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Chapter 4&5 Defining Classes Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Java Object Oriented Programming Encapsulation, Inheritance, Polymorphism (Java: An Eventful Approach - Ch. 17, 21.7), Slides Credit: Bruce, Danyluk and.
Object-Oriented Programming Chapter Chapter
Object Oriented Programing (OOP)
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
ADT data abstraction. Abstraction  representation of concepts by their relevant features only  programming has two major categories of abstraction process.
Polymorphism CMPS Poly-morphism Means “many-forms” Means different things in biology, chemistry, computer science Means different things to functional.
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.
OO in Context Lecture 13: Dolores Zage. Confused about OO Not alone, there is much confusion about OO many programs are claimed to be OO but are not really.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
Introduction to Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Principles of Programming. Achieving an Object-Oriented Design  Abstraction and Information Hiding  Object-Oriented Design  Functional Decomposition.
Exceptions and Handling
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CSCE 240 – Intro to Software Engineering Lecture 3.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Fall 2013 Chapter 10 Thinking.
Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract.
CSIS 123A Lecture 1 Intro To Classes Glenn Stevenson CSIS 113A MSJC.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Chapter 10 Thinking in Objects
Concepts of Object Oriented Programming
More Functional Decomposition
Chapter 10 Thinking in Objects
CHAPTER 5 GENERAL OOP CONCEPTS.
Chapter 10 Thinking in Objects
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Chapter 8 Namespaces and Memory Realities
Chapter 9 Thinking in Objects
IFS410: Advanced Analysis and Design
Teach A-Level Computer Science: Object-Oriented Programming in Python
More Functional Decomposition
Object-Oriented Programming Using C++ Second Edition
More Functional Decomposition
Chapter 9 Thinking in Objects
CPS120: Introduction to Computer Science
Object-Oriented Programming
More Functional Decomposition
CPS120: Introduction to Computer Science
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
More Functional Decomposition
Presentation transcript:

Chapter More on Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg

New Programming Assignment PA10

The Three OOP Factors Remember, we said there were 3 factors that distinguished an Object Oriented Programming language:  Encapsulation  Inheritance  Polymorphism

We are Still at Encapsulation Feature of encapsulation:  Hide details of the implementation so that the program is easier to read and write  Modularity, make an object so that it can be reused in other contexts  Provide an interface (the methods) that is the approved way to deal with the class In a similar way to other classes Ex: the in operator

Instance Variables An instance variable is a variable inside of a class that stores information for a particular object In which class method do these variables first appear with some sort of initial value? 5

Let’s look at an updated version of the Student Class

How do we compute GPA? 7

First, convert letter grade into the number equivalent  A- is 3.67, C+ is 2.33, etc. Next, multiply the number of credits by the letter grade’s number equivalent to get a specific course’s grade point Finally, add up the number of grade points and divide by the total number of credits 8

Method Types Which class methods in class Student are accessor methods? Which class methods in class Student are mutator methods? 9

Two types of programmers now Programmer that builds the class Programmer that uses the class 10

Private Values We briefly talked about why class users may not want to access instance variables directly print(s1.firstNameStr) By only accessing data through methods, the class programmers are free to change how the class works  E.g. changing a variable name or adding new variables

Private Variables in an Instance Many OOP approaches allow you to make a variable or function in an instance private. Private means not accessible by the class user, only the class developer. There are advantages to controlling who can access the instance values.

‘Privacy’ in Python Python takes the approach “We are all adults here.” No hard restrictions. Python implements this notion of privacy with the underscore: _  Which functions have we already seen with double underscores?

‘Privacy’ in Python Provides naming to avoid accidents. Use _ in front of any variable Let’s modify our Student class to do that 14