Accessor Functions 04/13/11. Encapsulation  Like case on my watch Protect from outside Protect from outside Have member functions control data Have member.

Slides:



Advertisements
Similar presentations
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
CS0007: Introduction to Computer Programming Introduction to Classes and Objects.
1 Classes, Encapsulation, Methods and Constructors (Continued) Class definitions Instance data Encapsulation and Java modifiers Method declaration and.
Beginning C++ Through Game Programming, Second Edition by Michael Dawson.
Constructors 11/10/10. Today  Use constructors to initialize objects.  Use const to protect data members.
CS-2135 Object Oriented Programming
Exercise Exercise3.1 8 Exercise3.1 9 Exercise
Exercise Exercise Exercise Exercise
Exercise Exercise Exercise Exercise
ECE122 L6: Problem Definition and Implementation February 15, 2007 ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation.
Exercise Exercise6.1 7 Exercise6.1 8 Exercise6.1 9.
1 Writing a Good Program 5. Objects and Classes in C++
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Structures 11/5/10. Reading  Read pp  Review of scope ch6/review.cpp ch6/review.cpp What is the output? What is the output?
UML Basics & Access Modifier
Classes and Class Members Chapter 3. 3 Public Interface Contract between class and its clients to fulfill certain responsibilities The client is an object.
Packages. Package A package is a set of related classes Syntax to put a class into a package: package ; public class { …} Two rules:  A package declaration.
Visual Programming Fall 2012 – FUUAST Topic: Development environment.
Introduction To Classes Chapter Procedural And Object Oriented Programming Procedural programming focuses on the process/actions that occur in a.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Procedural and Object-Oriented Programming 13.1.
Chapter 4 -2 part Writing Classes 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA ‏ Visibility Control.
Classes In C++ 1. What is a class Can make a new type in C++ by declaring a class. A class is an expanded concept of a data structure: instead of holding.
Classes Definition A class is a data type whose variables are objects Object – a variable that has member functions as well the ability to hold.
CSC1401 Classes - 2. Learning Goals Computing concepts Adding a method To show the pictures in the slide show Creating accessors and modifiers That protect.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
© 2004 Pearson Addison-Wesley. All rights reserved September 14, 2007 Anatomy of a Method ComS 207: Programming I (in Java) Iowa State University, FALL.
Rina System development with Java Instructors: Rina Zviel-Girshin Lecture 4.
Copyright © 2002 W. A. Tucker1 Chapter 10 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Classes and Objects CS177 Rec 10. Announcements Project 4 is posted ◦ Milestone due on Nov. 12. ◦ Final submission due on Nov. 19. Exam 2 on Nov. 4 ◦
Department of Computer Science Data Structures Using C++ 2E Chapter 2 Object-Oriented Design (OOD) and C++  Learn about inheritance  Learn about derived.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
Object-Oriented Programming (OOP) What we did was: (Procedural Programming) a logical procedure that takes input data, processes it, and produces output.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Topic 8Classes, Objects and Methods 1 Topic 8 l Class and Method Definitions l Information Hiding and Encapsulation l Objects and Reference Classes, Objects,
Access Control to Class Members tMyn1 Access Control to Class Members In its support for encapsulation, the class provides two major benefits. First, it.
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
Classes: Defining Your Own Data Types Basic principles in OOP Define a new data type as a class and use objects of a class Member Functions –Constructors.
Chapter 8 Systems of Linear Equations in Two Variables Section 8.3.
Outline Anatomy of a Class Encapsulation Anatomy of a Method Copyright © 2014 Pearson Education, Inc.
C++ Objects and Scope. Important Definitions  Class  Access and Visibility  Encapsulation  Unified Modeling Language (UML)  Constructor  Destructor.
OOP Details Constructors, copies, access. Initialize Fields are not initialized by default:
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Constructors; Encapsulation reading: self-checks: #13-18,
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
1 More About Derived Classes and Inheritance Chapter 9.
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.
Copyright © 2012 Pearson Education, Inc. Chapter 4 Writing Classes : Review Java Software Solutions Foundations of Program Design Seventh Edition John.
OOP: Encapsulation &Abstraction
Objects as a programming concept
Encapsulation, Data Hiding and Static Data Members
10.2 Classes Copyright © 2008 Pearson Addison-Wesley. All rights reserved. 1.
Encapsulation.
Encapsulation & Visibility Modifiers
Ch 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: Classes and Objects.
Building Java Programs
Classes, Encapsulation, Methods and Constructors (Continued)
Features of OOP Abstraction Encapsulation Data Hiding Inheritance
10:00.
Private.
Measuring Variation 2 Lecture 17 Sec Mon, Oct 3, 2005.
CLASSES AND OBJECTS.
Welcome back to Software Development!
Outline Anatomy of a Class Encapsulation Anatomy of a Method
NAME 436.
Information Hiding and Encapsulation Section 4.2
Building Java Programs
CSG2H3 Object Oriented Programming
Presentation transcript:

Accessor Functions 04/13/11

Encapsulation  Like case on my watch Protect from outside Protect from outside Have member functions control data Have member functions control data Like buttons on watchLike buttons on watch

Access Specifiers  Indicate accessibility of class members  public: Open access to outside functions Open access to outside functions Member functions are usually public. Member functions are usually public.  private: Access restricted to other members of class Access restricted to other members of class Member variables private Member variables private  Example: sec6.2/rectangle.cpp

Accessor Functions  Main program can't directly access private data members.  Create accessor function to allow access. Name usually begins with “get” Name usually begins with “get”  dog.cpp

Review  ch6/review.cpp Why doesn't the program compile? Why doesn't the program compile? Use accessors to let the main get the degrees and scale. Use accessors to let the main get the degrees and scale. What would the accessor functions be? What would the accessor functions be?

TIMERa  Look at TIMERa exercise in sec6.2 directory.  Good exercise to do on your own.