1 / 7

CS 331, Principles of Programming Languages

This chapter explores the concepts of objects, classes, subclasses, and class hierarchy in object-oriented programming languages. Learn about encapsulation, methods, messages, and multiple inheritance. Understand the properties and operations of binary trees and binary search trees.

rlim
Download Presentation

CS 331, Principles of Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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, newData:someDataType) • 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

More Related