CS 331, Principles of Programming Languages - PowerPoint PPT Presentation

About This Presentation
Title:

CS 331, Principles of Programming Languages

Description:

Boolean search(K: key) cleanOut(K: key) The Binary search tree class may have the same properties as Binary Tree and Searchable Thing ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 8
Provided by: charlesn
Category:

less

Transcript and Presenter's Notes

Title: CS 331, Principles of Programming Languages


1
CS 331, Principles of Programming Languages
  • Chapter 7
  • Object-Oriented Programming

2
What is an object?
  • Represents some important entity in the
    application
  • Has external and internal properties, which
    include some
  • data, and
  • operations to be applied to that data
  • May be one of several similar objects

3
Terminology
  • An object is an encapsulation of data and
    operations
  • A class is a set of objects that have the same or
    similar properties (i.e. data and operations)
  • A subclass is a subset of a class, with
    additional properties

4
More Terminology
  • An individual object belonging to a given class
    is an instance of that class
  • A method is a procedure body that implements an
    operation
  • A message is a request to execute a method
  • note that a message may or may not involve
    inter-process communication

5
Class Hierarchy?
  • A subclass is derived from at least one parent
    class
  • operations in the class can be applied to objects
    in any subclass, unless redefined
  • Instances of subclass objects may have additional
    operations that can be applied
  • Some OOPLs support multiple inheritance, where a
    class may have more than one parent

6
Classes and subclasses
  • Tree
  • node root(t tree)
  • height(n node)
  • n_of_immediate_descendants(n node)
  • Binary tree
  • left_child(n node) right_child(n node)
  • Binary search tree
  • tree insert(key K, value someDataType)

7
Another Parent Class?
  • Class SearchableThing
  • insert(K key, newDatasomeDataType)
  • someDataType retrieve(K key)
  • Boolean search(K key)
  • cleanOut(K key)
  • The Binary search tree class may have the same
    properties as Binary Tree and Searchable Thing
Write a Comment
User Comments (0)
About PowerShow.com