Objects, Classes, and Inheritance

Size: px
Start display at page:

Download "Objects, Classes, and Inheritance"

Transcription

1 Object, Clae, and Inheritance CS111 Computer Programming Department of Computer Science Welleley College The Big Picture Some paradigm of programming: o Imperative Programming Program pecified by conditional, loop, procedure that change variable and mutable data tructure over time. o Functional Programming Program pecified a compoition of function that create new immutable data tructure. Higher-order function are important building block (e.g, map, filter o Object Oriented Programming (OOP Program pecified in term of interacting tateful object whoe behavior i decribed by method. Motivation: Python ha lot of object-oriented feature that we ve ued, but it would be nice to define our own object. Today: Study object with imple example Next time: Ue object in animation Three paradigm of programming we cover in CS111. Object and Clae 2 Object An object i a data value that ha tate and behavior. Example: Python builtin type: number, tring, lit, tuple, dictionarie, c1graphic: circle, canvae, point, Object behavior are defined by method that can be invoked on an object. A method i a function that ha direct acce to the tate of an object. For example, method of a tring object include: "Computer Science".lower( "Computer Science".plit( "Computer Science".index('c' Different kind of object can handle the ame method in different way. For example,.cale( Everything in Python i an object (even function. cale the radiu of a c1graphic le object by cale the and of a c1graphic angle object by Clae A cla define the characteritic of a et of object or intance, including: Repreentation of State: how each object' tate i tored a intance variable in that object Implementation of Behavior: how object behavior i implemented a code for each object' method A cla i ued a a template for making object of one kind. An object made from a cla i called an intance of the cla. Example of clae include: tr lit int dict Canva Polygon le Layer Object are known a intance of a cla. Type help(tr or help(canvato ee all the method of thee clae. Object and Clae 3 Object and Clae 4

2 Cla Example: Geometric Figure State i repreented by intance variable, behavior through method. Define abtract geometric figure clae for circle, rectangle, etc. (Different from thoe in c1graphic! Thee figure do not have poition and we will not draw them! State: o The tate of a circle i it radiu and o The tate of a rectangle i it,, and o The tate of a quare i it ide length and Object Memory Diagram Object memory diagram reemble thoe of r = (2, 1, "red" dictionarie. We call our clae and to dik = (50, "yellow" ditinguih them from the c1graphic = (,, le and angle clae. Object a cloud named by cla name containing intance variable (alo known a attribute, Object drawn member, a boxe or named field by cla name containing intance variable (alo known a attribute, member, or field r 2 1 dik radiu 50 "red" "yellow" Behavior: o Method that return the tate element o Method that change the tate element o Method to compute the perimeter & area of each figure Object and Clae 5 le dik radiu 50 Ditinct intance of one cla have the ame "yellow" method and intance variable name, but they each hold ditinct intance variable content. Object and Clae 6 Big idea #1: Abtraction for Object Client Ue object method to inpect or manipulate abtract tate. hape.area(.getcolor(.etcolor(c hape.area( Contract / API: Method.area(.getColor(.etColor(c Implementation Concrete tate (intance variable and behavior (method code hape Client code ue object and their method without awarene of implementation. radiu "yellow" cla : return ( math.pi *.radiu**2 Object and Clae 7 Method Contructor function invocation = (,, Method invocation.getwidth(.getheight(.getcolor(.perimeter( 54.area( 0 Some method change the tate of an object rather than returning omething.etwidth(30.etheight(25 To Notice - The contructor name tart in uppercae; it ha the name of the cla. - Some method only return a value, they are known a getter method. - Some method change value, are known a etter method. Object and Clae 8

3 Defining a Cla Keyword cla init method uually declare intance variable Definition of intance method cla name init i pecial method automatically invoked each time a new object i created cla : '''A rectangle, pecified by,, and ''' def init (, w, h, c:. = c Firt argument for any intance method i the receiver object that the method i invoked upon def getwidth(: """Return the rectangle' """... A cla a a collection of function definition. They are all bound to the cla body. Object and Clae 9 def init (, w, h, c:. = c How to invoke the contructor: (,, cla name To Notice - The pecial method init ha two undercore at the tart and end. - The contructor function implicitly call init. - Although the init definition ha four parameter, during the invocation we provide only three argument. The pecial variable doen t receive a value explicitly. Object and Clae (,, The memory diagram (tep-by-tep for creating an object during the contructor invocation. (,, 1. Invoke init method with bound to new empty object for the cla and other parameter bound to contructor function argument 2. Execute tatement in body of init method. Thee may add new intance variable to object. init. = c w h init. = c w h c c Object and Clae 11 Object and Clae 12

4 (,, 2. Execute tatement in body of init method. Thee may add new intance variable to object. (,, 2. Execute tatement in body of init method. Thee may add new intance variable to object. init. = c w h init. = c w h c c Important: in thi example, parameter name are different from intance variable name in the object (w v.. Object and Clae 13 You could name them the ame, ( intead of w, but the functionality would remain the ame. Object and Clae 14 Invoking an Intance Method: getwidth (,, 3. Object i returned a the reult of contructor invocation = (,, def getwidth(:.getwidth( 1. Invoke getwidth method with bound to the receiver object argument. getwidth Why? Behavior i aociated with an object. Invoking a method end a meage (getwidth to the receiver object. The receiver object repond by running it getwidth method on it. A method i jut a function, but need an argument indicating the receiver object. The receiver i a pecial argument that alo determine what getwidth method i ued. Object and Clae The receiver argument i written differently to ditinguih it from other argument.

5 Invoking an Intance Method: getwidth Invoking an Intance Method: getwidth = (,, def getwidth(:.getwidth( = (,, def getwidth(:.getwidth( 2. Statement in the body are executed 3. Value i returned a reult of method invocation. getwidth Object and Clae Object and Clae 18 Invoking an Intance Method: etwidth Invoking an Intance Method: etwidth = (,, def etwidth(, newwidth:. = newwidth = (,, def etwidth(, newwidth:. = newwidth 30.etWidth(30.etWidth(30 1. Invoke etwidth method with bound to receiver object and newwidth bound to the argument 2. Statement in the body are executed etwidth etwidth. = newwidth. = 30 newwidth 30 newwidth 30 Object and Clae 19 Object and Clae 20

6 Invoking an Intance Method: etwidth = (,, def etwidth(, newwidth:. = newwidth.etwidth(30 3. Here, nothing i returned a reult of method invocation ince there i no return tatement 30 Object and Clae 21 Define the entire cla cla : def init (, w, h, c:. = c def getwidth(: def getheight(: return. def getcolor(: return. def etwidth(, newwidth:. = newwidth def etheight(, newheight:. = newheight def etcolor(, newcolor:. = newcolor *. def perimeter(: return 2*(.+. def cale(, factor:. *= factor. *= factor To Notice - All method of the cla have the pecial variable a their firt parameter. - Intance variable are acceed through the pecial variable in all method. - We will normally have one line of pace after each function definition, but here it i omitted due to lack of pace. - Additionally, doctring are miing for the ame reaon. Object and Clae 22 repr method o What happen if you print a object? (try thi in the notebook = (,, print o We'd like to control how the object i repreented when diplayed. Thi i done with the repr method o Method name with around them are handled by Python in a pecial way o repr alway take only a an argument and return a tring def repr (: return ' <: {}, : {}, : {}>'.format(.,.,. Object and Clae 23 Now define the cla in the notebook cla : def init (, radiu, : """make a circle with the given radiu and """ def getradiu(: """return radiu of circle""" def getcolor(: """return of circle""" def etradiu(, radiu: """change radiu""" def etcolor(, : """change """ """return area of circle""" def perimeter(: """return perimeter (circumference"" def cale(, factor: """multiply the circle radiu by factor""" def repr (: """tring repreentation of circle""" Object and Clae 24

7 So far in thi lecture: Object are data value with tate (tored in intance variable and behavior (implemented a method. Clae are template for creating object of one kind. Cla definition tart with the keyword cla and all the method included in the body of the cla. To intantiate an object we invoke the contructor, a function with the cla' name, which create a new object intance, invoke init on it, and return the new intance. The firt parameter of a method definition i the pecial variable. Coming up Polymorphim: Code can ue any kind of object with the ame method. Why not dictionarie? Create your own MutableString cla. Inheritance: Clae can inherit method from other clae to hare and reue behavior and code. Object and Clae 25 Big idea #1+2: Abtraction and Modularity for Polymorphim (1 Code that interact with an object by invoking it method can ue any object that provide the right method, regardle of that object' internal. Client hape = [ (2,, (4, 3, "red" ] # totalarea = um([.area( for in hape ] Work for any object with a.area( method that return a number. Contract / API: Method.area( hape radiu 2 Implementation 0 1 cla : return ( math.pi *.radiu**2 4 3 "red" cla : return (. *. Object and Clae 26 Big idea #1+2: Abtraction and Modularity for Polymorphim (2 A well defined abtraction allow multiple implementation. A well defined abtraction make it eay to ue alternative implementation later. Client = ( # print.area( Work for any repreentation of. No change needed in client code when implementation change. Contract / API: Method.area( Diameter-baed diam 4 cla : return ( math.pi * (.diam/2**2 Implementation "red" Radiu-baed radiu 2 "red" cla : return ( math.pi *.radiu**2 Object and Clae 27 Why not Dictionarie? One attempt: what if we wih to wap implementation? def makedict(w, h, c: return {'figtype': '', '': w, '': h, '': c} def makedict(r, c: return {'figtype': '', 'radiu': w, '': c} def etwidth(fig, : # call with etwidth(myfig, 3, v. myfig.etwidth(3 if fig['figtype'] == '': return fig[''] = elif fig['figtype'] == '': raie Exception(' doe not upport etwidth' # Add one branch for every type of hape. def area(fig: # call with area(myfig, v. myfig.area( if fig['figtype'] == '': return fig[''] * fig[''] elif fig['figtype'] == '': return math.pi * fig['radiu']**2 # Add one branch for every type of hape. Object and Clae 28

8 Python String are Immutable In [11]: = 'eed' In [12]: [2] = 'n' TypeError: 'tr' object doe not upport item aignment Let Define a Mutable String Cla Create a MutableString cla that upport the following behavior: getting a character at a given index changing a character at a given index to a new value getting the length of the mutable tring revering the mutable tring returning a tring repreentation of the mutable tring We can create new tring that are baed on exiting tring: In [13]: 2 = [:2] + 'n' + [3:] In [14]: 2 Out[14]: 'end' But we cannot modify an exiting tring. Object and Clae 29 = MutableString('deer' print deer print.length( 4 print.getchar(3 r.revere( print reed.etchar(0, '' print eed.etchar(2, 'n' print end Object and Clae 30 Mutable String Cla cla MutableString: def init (, data: # make a MutableString def length(: # return number of char def getchar(, index: # return char at index def etchar(, index, c: # change char at index to c def revere(: # revere char of object def repr (: # tring rep of object Big idea #1+2: Abtraction and Modularity upport alternative implementation A well defined abtraction allow multiple implementation. A well defined abtraction make it eay to ue alternative implementation later. Client = MutableString( "hello world".etchar(0, 'c' print Work for both implementation of MutableString. Contract / API: Method.area( String-baed MutableString tring "cello world" Implementation Lit-baed MutableString char 'c' 'e' 'l' 'l' 'o' ' ' 'w' 'o' 'r' 'l' 'd' Object and Clae 31 Object and Clae 32

9 Special Syntax & Method Name for Collection Method Python tranlate pecial yntax for familiar collection operator into method name that involve. For example: len(coll coll. len ( coll[index] coll. getitem (index coll[index] = newval coll. etitem (index, newval coll1 + coll2 coll1. add (coll2 elt in coll coll. contain (elt So in MutableString,if we rename length to len, getchar to getitem, and etchar to etitem, we can ue the pecial yntax: = MutableString('deer' print len( [3] = 'p' print print [3] Object and Clae 33 A hierarchy of figure o Notice that and have: o Method with the ame name but different implementation area, perimeter, cale o Method with the ame name AND the ame implementation getcolor, etcolor o Method that are unique to each cla in name a well a implementation getradiu, getradiu, getwidth, etwidth, getheight, etheight o Thi will be the cae for other figure clae we might define too (Square, Triangle, etc. o How can we follow the DRY (Don't Repeat Your principle? Object and Clae 34 A hierarchy of figure Inheritance Fig Triang Squ Inheritance i a mechanim for abtracting over data and behavior common to different clae When cla B inherit from cla A, cla B acquire all of the attribute (intance variable and method from cla A. New attribute (intance variable and method can be added to B. B i called the child cla or the ubcla. A i called the parent cla or the upercla. Each cla "inherit" all the method of it parent Object and Clae 35 Object and Clae 36

10 Child Clae Squ (quare are a pecific kind of (rectangle cla Squ(: # inherit all method # plu can define extra one def getsidelen(: def etsidelen(, idelen:. = idelen. = idelen Abtraction: Uer of Squ doe not need to know that it ue and A ubcla method with the ame name a an inherited upercla method replace or override the inherited method. def init (, idelen, : # ue the contructor. init (, idelen, idelen, Object and Clae 37 Parent Clae and have hared method name and definition cla : cla : def init (, w, h, c:. = c def getwidth(: def getheight(: return. def getcolor(: return. def etwidth(, w: def etheight(, h: def etcolor(, c:. = c *. def perimeter(: return 2*(.+. def cale(, factor:. *= factor. *= factor def init (, rad, c:.radiu = rad. = c def getradiu(: return.radiu Code in blue how repetition. def getcolor(: return. def etradiu(, rad:.radiu = rad def etcolor(, c:. = c return pi*.radiu**2 def perimeter(: return 2*pi*.radiu def cale(, factor:.radiu *= factor Object and Clae 38 Parent Clae: Define a cla Fig to capture common tate and behavior and will inherit from Fig (ee notebook cla Fig: def init (, :. = def getcolor(: return. def etcolor(, :. = pa def perimeter(: pa def cale(, factor: pa and can now inherit from Fig cla (Fig: def init (, radiu, : Fig. init (,.radiu = radiu # other definition the ame, but no need # to define getcolor and etcolor cla (Fig: def init (,,, : Fig. init (, idth eight # other definition the ame, but no need # to define getcolor and etcolor Object and Clae 39 Object and Clae 40

11 Inheritance: c1graphic Clae are often defined in inheritance hierarchie to maximize haring and reue of behavior (method code. Object and Clae 41 Benefit of Object-Oriented Programming Modularity: Common tate and behavior packaged up Polymorphim: Same method can do different thing for different type of object (e.g., perimeter for Fig Encapulation: Hide detail of how we tore the object' information (e.g., different implementation of MutableString Not actually enforced in Python. Java upport private variable and method that can be ued only within method of the cla. Inheritance: Subclae hare tate and behavior of uperclae (avoiding repetition of code Object and Clae 42

Objects and Classes. The Big Picture. Classes. Objects. Some paradigms of programming:

Objects and Classes. The Big Picture. Classes. Objects. Some paradigms of programming: Object and Clae The Big Picture Some paradigm of programming: Imperative Programming ue explicit loop, conditional, variable Three paradigm of programming we cover in CS111. Functional Programming Ue function

More information

Representations and Transformations. Objectives

Representations and Transformations. Objectives Repreentation and Tranformation Objective Derive homogeneou coordinate tranformation matrice Introduce tandard tranformation - Rotation - Tranlation - Scaling - Shear Scalar, Point, Vector Three baic element

More information

A SIMPLE IMPERATIVE LANGUAGE THE STORE FUNCTION NON-TERMINATING COMMANDS

A SIMPLE IMPERATIVE LANGUAGE THE STORE FUNCTION NON-TERMINATING COMMANDS A SIMPLE IMPERATIVE LANGUAGE Eventually we will preent the emantic of a full-blown language, with declaration, type and looping. However, there are many complication, o we will build up lowly. Our firt

More information

Lecture Outline. Global flow analysis. Global Optimization. Global constant propagation. Liveness analysis. Local Optimization. Global Optimization

Lecture Outline. Global flow analysis. Global Optimization. Global constant propagation. Liveness analysis. Local Optimization. Global Optimization Lecture Outline Global flow analyi Global Optimization Global contant propagation Livene analyi Adapted from Lecture by Prof. Alex Aiken and George Necula (UCB) CS781(Praad) L27OP 1 CS781(Praad) L27OP

More information

MAT 155: Describing, Exploring, and Comparing Data Page 1 of NotesCh2-3.doc

MAT 155: Describing, Exploring, and Comparing Data Page 1 of NotesCh2-3.doc MAT 155: Decribing, Exploring, and Comparing Data Page 1 of 8 001-oteCh-3.doc ote for Chapter Summarizing and Graphing Data Chapter 3 Decribing, Exploring, and Comparing Data Frequency Ditribution, Graphic

More information

CORRECTNESS ISSUES AND LOOP INVARIANTS

CORRECTNESS ISSUES AND LOOP INVARIANTS The next everal lecture 2 Study algorithm for earching and orting array. Invetigate their complexity how much time and pace they take Formalize the notion of average-cae and wort-cae complexity CORRECTNESS

More information

CS201: Data Structures and Algorithms. Assignment 2. Version 1d

CS201: Data Structures and Algorithms. Assignment 2. Version 1d CS201: Data Structure and Algorithm Aignment 2 Introduction Verion 1d You will compare the performance of green binary earch tree veru red-black tree by reading in a corpu of text, toring the word and

More information

1 The secretary problem

1 The secretary problem Thi i new material: if you ee error, pleae email jtyu at tanford dot edu 1 The ecretary problem We will tart by analyzing the expected runtime of an algorithm, a you will be expected to do on your homework.

More information

Note 2: Transformation (modeling and viewing)

Note 2: Transformation (modeling and viewing) Note : Tranformation (modeling and viewing Reading: tetbook chapter 4 (geometric tranformation and chapter 5 (viewing.. Introduction (model tranformation modeling coordinate modeling tranformation world

More information

Operational Semantics Class notes for a lecture given by Mooly Sagiv Tel Aviv University 24/5/2007 By Roy Ganor and Uri Juhasz

Operational Semantics Class notes for a lecture given by Mooly Sagiv Tel Aviv University 24/5/2007 By Roy Ganor and Uri Juhasz Operational emantic Page Operational emantic Cla note for a lecture given by Mooly agiv Tel Aviv Univerity 4/5/7 By Roy Ganor and Uri Juhaz Reference emantic with Application, H. Nielon and F. Nielon,

More information

Topics. Lecture 37: Global Optimization. Issues. A Simple Example: Copy Propagation X := 3 B > 0 Y := 0 X := 4 Y := Z + W A := 2 * 3X

Topics. Lecture 37: Global Optimization. Issues. A Simple Example: Copy Propagation X := 3 B > 0 Y := 0 X := 4 Y := Z + W A := 2 * 3X Lecture 37: Global Optimization [Adapted from note by R. Bodik and G. Necula] Topic Global optimization refer to program optimization that encompa multiple baic block in a function. (I have ued the term

More information

Lecture 14: Minimum Spanning Tree I

Lecture 14: Minimum Spanning Tree I COMPSCI 0: Deign and Analyi of Algorithm October 4, 07 Lecture 4: Minimum Spanning Tree I Lecturer: Rong Ge Scribe: Fred Zhang Overview Thi lecture we finih our dicuion of the hortet path problem and introduce

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Delaunay Triangulation: Incremental Construction

Delaunay Triangulation: Incremental Construction Chapter 6 Delaunay Triangulation: Incremental Contruction In the lat lecture, we have learned about the Lawon ip algorithm that compute a Delaunay triangulation of a given n-point et P R 2 with O(n 2 )

More information

Laboratory Exercise 2

Laboratory Exercise 2 Laoratory Exercie Numer and Diplay Thi i an exercie in deigning cominational circuit that can perform inary-to-decimal numer converion and inary-coded-decimal (BCD) addition. Part I We wih to diplay on

More information

Drawing Lines in 2 Dimensions

Drawing Lines in 2 Dimensions Drawing Line in 2 Dimenion Drawing a traight line (or an arc) between two end point when one i limited to dicrete pixel require a bit of thought. Conider the following line uperimpoed on a 2 dimenional

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

ES205 Analysis and Design of Engineering Systems: Lab 1: An Introductory Tutorial: Getting Started with SIMULINK

ES205 Analysis and Design of Engineering Systems: Lab 1: An Introductory Tutorial: Getting Started with SIMULINK ES05 Analyi and Deign of Engineering Sytem: Lab : An Introductory Tutorial: Getting Started with SIMULINK What i SIMULINK? SIMULINK i a oftware package for modeling, imulating, and analyzing dynamic ytem.

More information

Laboratory Exercise 6

Laboratory Exercise 6 Laboratory Exercie 6 Adder, Subtractor, and Multiplier The purpoe of thi exercie i to examine arithmetic circuit that add, ubtract, and multiply number. Each type of circuit will be implemented in two

More information

SIMIT 7. Component Type Editor (CTE) User manual. Siemens Industrial

SIMIT 7. Component Type Editor (CTE) User manual. Siemens Industrial SIMIT 7 Component Type Editor (CTE) Uer manual Siemen Indutrial Edition January 2013 Siemen offer imulation oftware to plan, imulate and optimize plant and machine. The imulation- and optimizationreult

More information

Edits in Xylia Validity Preserving Editing of XML Documents

Edits in Xylia Validity Preserving Editing of XML Documents dit in Xylia Validity Preerving diting of XML Document Pouria Shaker, Theodore S. Norvell, and Denni K. Peter Faculty of ngineering and Applied Science, Memorial Univerity of Newfoundland, St. John, NFLD,

More information

Shortest Paths Problem. CS 362, Lecture 20. Today s Outline. Negative Weights

Shortest Paths Problem. CS 362, Lecture 20. Today s Outline. Negative Weights Shortet Path Problem CS 6, Lecture Jared Saia Univerity of New Mexico Another intereting problem for graph i that of finding hortet path Aume we are given a weighted directed graph G = (V, E) with two

More information

Computer Graphics. Transformation

Computer Graphics. Transformation (SBE 36) Dr. Aman Eldeib Spring 2 SBE 36 i a fundamental corner tone of computer graphic and i a central to OpenGL a well a mot other graphic tem.(2d and 3D ) Given an object, tranformation i to change

More information

Today s Outline. CS 561, Lecture 23. Negative Weights. Shortest Paths Problem. The presence of a negative cycle might mean that there is

Today s Outline. CS 561, Lecture 23. Negative Weights. Shortest Paths Problem. The presence of a negative cycle might mean that there is Today Outline CS 56, Lecture Jared Saia Univerity of New Mexico The path that can be trodden i not the enduring and unchanging Path. The name that can be named i not the enduring and unchanging Name. -

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract

More information

3D SMAP Algorithm. April 11, 2012

3D SMAP Algorithm. April 11, 2012 3D SMAP Algorithm April 11, 2012 Baed on the original SMAP paper [1]. Thi report extend the tructure of MSRF into 3D. The prior ditribution i modified to atify the MRF property. In addition, an iterative

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract

More information

KS3 Maths Assessment Objectives

KS3 Maths Assessment Objectives KS3 Math Aement Objective Tranition Stage 9 Ratio & Proportion Probabilit y & Statitic Appreciate the infinite nature of the et of integer, real and rational number Can interpret fraction and percentage

More information

Analyzing Hydra Historical Statistics Part 2

Analyzing Hydra Historical Statistics Part 2 Analyzing Hydra Hitorical Statitic Part Fabio Maimo Ottaviani EPV Technologie White paper 5 hnode HSM Hitorical Record The hnode i the hierarchical data torage management node and ha to perform all the

More information

Factor Graphs and Inference

Factor Graphs and Inference Factor Graph and Inerence Sargur Srihari rihari@cedar.bualo.edu 1 Topic 1. Factor Graph 1. Factor in probability ditribution. Deriving them rom graphical model. Eact Inerence Algorithm or Tree graph 1.

More information

Generic Traverse. CS 362, Lecture 19. DFS and BFS. Today s Outline

Generic Traverse. CS 362, Lecture 19. DFS and BFS. Today s Outline Generic Travere CS 62, Lecture 9 Jared Saia Univerity of New Mexico Travere(){ put (nil,) in bag; while (the bag i not empty){ take ome edge (p,v) from the bag if (v i unmarked) mark v; parent(v) = p;

More information

An Approach to a Test Oracle for XML Query Testing

An Approach to a Test Oracle for XML Query Testing An Approach to a Tet Oracle for XML Query Teting Dae S. Kim-Park, Claudio de la Riva, Javier Tuya Univerity of Oviedo Computing Department Campu of Vieque, /n, 33204 (SPAIN) kim_park@li.uniovi.e, claudio@uniovi.e,

More information

SIMIT 7. Profinet IO Gateway. User Manual

SIMIT 7. Profinet IO Gateway. User Manual SIMIT 7 Profinet IO Gateway Uer Manual Edition January 2013 Siemen offer imulation oftware to plan, imulate and optimize plant and machine. The imulation- and optimizationreult are only non-binding uggetion

More information

Parameters, UVM, Coverage & Emulation Take Two and Call Me in the Morning

Parameters, UVM, Coverage & Emulation Take Two and Call Me in the Morning Parameter, UVM, Coverage & Emulation Take Two and Call Me in the Morning Michael Horn Mentor Graphic Corporation Colorado, USA Mike_Horn@mentor.com Bryan Ramirez Mentor Graphic Corporation Colorado, USA

More information

New Structural Decomposition Techniques for Constraint Satisfaction Problems

New Structural Decomposition Techniques for Constraint Satisfaction Problems New Structural Decompoition Technique for Contraint Satifaction Problem Yaling Zheng and Berthe Y. Choueiry Contraint Sytem Laboratory Univerity of Nebraka-Lincoln Email: yzheng choueiry@ce.unl.edu Abtract.

More information

Iterators & Generators

Iterators & Generators Iterators & Generators Sequences A sequence is something that you can: Index into Get the length of What are some examples of sequences? Sequences We ve been working with sequences all semester! Examples:

More information

Laboratory Exercise 2

Laboratory Exercise 2 Laoratory Exercie Numer and Diplay Thi i an exercie in deigning cominational circuit that can perform inary-to-decimal numer converion and inary-coded-decimal (BCD) addition. Part I We wih to diplay on

More information

Separating Ownership Topology and Encapsulation with Generic Universe Types

Separating Ownership Topology and Encapsulation with Generic Universe Types Separating Ownerhip Topology and Encapulation with Generic Univere Type WERNER DIETL, Univerity of Wahington SOPHIA DROSSOPOULOU, Imperial College London PETER MÜLLER, ETH Zurich Ownerhip i a powerful

More information

Advanced Encryption Standard and Modes of Operation

Advanced Encryption Standard and Modes of Operation Advanced Encryption Standard and Mode of Operation G. Bertoni L. Breveglieri Foundation of Cryptography - AES pp. 1 / 50 AES Advanced Encryption Standard (AES) i a ymmetric cryptographic algorithm AES

More information

Chapter 13 Non Sampling Errors

Chapter 13 Non Sampling Errors Chapter 13 Non Sampling Error It i a general aumption in the ampling theory that the true value of each unit in the population can be obtained and tabulated without any error. In practice, thi aumption

More information

AUTOMATIC TEST CASE GENERATION USING UML MODELS

AUTOMATIC TEST CASE GENERATION USING UML MODELS Volume-2, Iue-6, June-2014 AUTOMATIC TEST CASE GENERATION USING UML MODELS 1 SAGARKUMAR P. JAIN, 2 KHUSHBOO S. LALWANI, 3 NIKITA K. MAHAJAN, 4 BHAGYASHREE J. GADEKAR 1,2,3,4 Department of Computer Engineering,

More information

CS1150 Principles of Computer Science Objects and Classes

CS1150 Principles of Computer Science Objects and Classes CS1150 Principles of Computer Science Objects and Classes Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Object-Oriented Thinking Chapters 1-8

More information

Select Operation (σ) It selects tuples that satisfy the given predicate from a relation (choose rows). Review : RELATIONAL ALGEBRA

Select Operation (σ) It selects tuples that satisfy the given predicate from a relation (choose rows). Review : RELATIONAL ALGEBRA Review : RELATIONAL ALGEBRA Relational databae ytem are expected to be equipped with a query language that can ait it uer to query the databae intance. There are two kind of query language relational algebra

More information

Keywords Cloud Computing, Service Level Agreements (SLA), CloudSim, Monitoring & Controlling SLA Agent, JADE

Keywords Cloud Computing, Service Level Agreements (SLA), CloudSim, Monitoring & Controlling SLA Agent, JADE Volume 5, Iue 8, Augut 2015 ISSN: 2277 128X International Journal of Advanced Reearch in Computer Science and Software Engineering Reearch Paper Available online at: www.ijarce.com Verification of Agent

More information

Chapter S:II (continued)

Chapter S:II (continued) Chapter S:II (continued) II. Baic Search Algorithm Sytematic Search Graph Theory Baic State Space Search Depth-Firt Search Backtracking Breadth-Firt Search Uniform-Cot Search AND-OR Graph Baic Depth-Firt

More information

Recall. Key terms. Review. Encapsulation (by getters, setters, properties) OOP Features. CSC148 Intro. to Computer Science

Recall. Key terms. Review. Encapsulation (by getters, setters, properties) OOP Features. CSC148 Intro. to Computer Science CSC148 Intro. to Computer Science Lecture 3: designing classes, special methods, composition, inheritance, Stack, Sack Amir H. Chinaei, Summer 2016 Office Hours: R 10-12 BA4222 ahchinaei@cs.toronto.edu

More information

Programs as Models. Procedural Paradigm. Class Methods. CS256 Computer Science I Kevin Sahr, PhD. Lecture 11: Objects

Programs as Models. Procedural Paradigm. Class Methods. CS256 Computer Science I Kevin Sahr, PhD. Lecture 11: Objects CS256 Computer Science I Kevin Sahr, PhD Lecture 11: Objects 1 Programs as Models remember: we write programs to solve realworld problems programs act as models of the real-world problem to be solved one

More information

Minimum congestion spanning trees in bipartite and random graphs

Minimum congestion spanning trees in bipartite and random graphs Minimum congetion panning tree in bipartite and random graph M.I. Otrovkii Department of Mathematic and Computer Science St. John Univerity 8000 Utopia Parkway Queen, NY 11439, USA e-mail: otrovm@tjohn.edu

More information

Quadrilaterals. Learning Objectives. Pre-Activity

Quadrilaterals. Learning Objectives. Pre-Activity Section 3.4 Pre-Activity Preparation Quadrilateral Intereting geometric hape and pattern are all around u when we tart looking for them. Examine a row of fencing or the tiling deign at the wimming pool.

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

Motivation: Level Sets. Input Data Noisy. Easy Case Use Marching Cubes. Intensity Varies. Non-uniform Exposure. Roger Crawfis

Motivation: Level Sets. Input Data Noisy. Easy Case Use Marching Cubes. Intensity Varies. Non-uniform Exposure. Roger Crawfis Level Set Motivation: Roger Crawfi Slide collected from: Fan Ding, Charle Dyer, Donald Tanguay and Roger Crawfi 4/24/2003 R. Crawfi, Ohio State Univ. 109 Eay Cae Ue Marching Cube Input Data Noiy 4/24/2003

More information

Lecture 8: More Pipelining

Lecture 8: More Pipelining Overview Lecture 8: More Pipelining David Black-Schaffer davidbb@tanford.edu EE8 Spring 00 Getting Started with Lab Jut get a ingle pixel calculating at one time Then look into filling your pipeline Multiplier

More information

The Pyth Language. Administrivia

The Pyth Language. Administrivia Administrivia The Pyth Language Lecture 5 Please make sure you have registered your team, created SSH keys as indicated on the admin page, and also have electronically registered with us as well. Prof.

More information

Description of background ideas, and the module itself.

Description of background ideas, and the module itself. CO3008 Semantic of Programming Language 1 Chapter 1 Decription of background idea, and the module itelf. Review ome mathematic. CO3008 Semantic of Programming Language 2 Overview: Background Introduction

More information

CISC 1600 Lecture 3.1 Introduction to Processing

CISC 1600 Lecture 3.1 Introduction to Processing CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists

More information

Package sound. R topics documented: November 10, Version Date Title A Sound Interface for R

Package sound. R topics documented: November 10, Version Date Title A Sound Interface for R Verion 1.4.5 Date 2017-11-10 Title A Sound Interface for R Package ound November 10, 2017 Author Matthia Heymann Maintainer Stefan Langenberg Depend R

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module

More information

DAROS: Distributed User-Server Assignment And Replication For Online Social Networking Applications

DAROS: Distributed User-Server Assignment And Replication For Online Social Networking Applications DAROS: Ditributed Uer-Server Aignment And Replication For Online Social Networking Application Thuan Duong-Ba School of EECS Oregon State Univerity Corvalli, OR 97330, USA Email: duongba@eec.oregontate.edu

More information

Lecture 19: Subclasses & Inheritance (Chapter 18)

Lecture 19: Subclasses & Inheritance (Chapter 18) http://www.cs.cornell.edu/courses/cs1110/2018sp Lecture 19: Subclasses & Inheritance (Chapter 18) CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner,

More information

else end while End References

else end while End References 621-630. [RM89] [SK76] Roenfeld, A. and Melter, R. A., Digital geometry, The Mathematical Intelligencer, vol. 11, No. 3, 1989, pp. 69-72. Sklanky, J. and Kibler, D. F., A theory of nonuniformly digitized

More information

Inheritance, and Polymorphism.

Inheritance, and Polymorphism. Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to

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

xy-monotone path existence queries in a rectilinear environment

xy-monotone path existence queries in a rectilinear environment CCCG 2012, Charlottetown, P.E.I., Augut 8 10, 2012 xy-monotone path exitence querie in a rectilinear environment Gregory Bint Anil Mahehwari Michiel Smid Abtract Given a planar environment coniting of

More information

Now consider the following situation after deleting three elements from the queue...

Now consider the following situation after deleting three elements from the queue... Scheme of valuvation -1I Subject & Code : Data Structure and Application (15CS33) NOTE: ANSWER All FIVE QUESTIONS 1 Explain the diadvantage of linear queue and how it i olved in circular queue. Explain

More information

How to. write a paper. The basics writing a solid paper Different communities/different standards Common errors

How to. write a paper. The basics writing a solid paper Different communities/different standards Common errors How to write a paper The baic writing a olid paper Different communitie/different tandard Common error Reource Raibert eay My grammar point Article on a v. the Bug in writing Clarity Goal Conciene Calling

More information

Service and Network Management Interworking in Future Wireless Systems

Service and Network Management Interworking in Future Wireless Systems Service and Network Management Interworking in Future Wirele Sytem V. Tountopoulo V. Stavroulaki P. Demeticha N. Mitrou and M. Theologou National Technical Univerity of Athen Department of Electrical Engineering

More information

Making New instances of Classes

Making New instances of Classes Making New instances of Classes NOTE: revised from previous version of Lecture04 New Operator Classes are user defined datatypes in OOP languages How do we make instances of these new datatypes? Using

More information

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3:

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3: PROGRAMMING ASSIGNMENT 3: Read Savitch: Chapter 7 Programming: You will have 5 files all should be located in a dir. named PA3: ShapeP3.java PointP3.java CircleP3.java RectangleP3.java TriangleP3.java

More information

On successive packing approach to multidimensional (M-D) interleaving

On successive packing approach to multidimensional (M-D) interleaving On ucceive packing approach to multidimenional (M-D) interleaving Xi Min Zhang Yun Q. hi ankar Bau Abtract We propoe an interleaving cheme for multidimenional (M-D) interleaving. To achieved by uing a

More information

22. Inheritance. Java. Summer 2008 Instructor: Dr. Masoud Yaghini

22. Inheritance. Java. Summer 2008 Instructor: Dr. Masoud Yaghini 22. Inheritance Java Summer 2008 Instructor: Dr. Masoud Yaghini Outline Superclasses and Subclasses Using the super Keyword Overriding Methods The Object Class References Inheritance Object-oriented programming

More information

ETSI TS V ( )

ETSI TS V ( ) TS 122 153 V14.4.0 (2017-05) TECHNICAL SPECIFICATION Digital cellular telecommunication ytem (Phae 2+) (GSM); Univeral Mobile Telecommunication Sytem (UMTS); LTE; Multimedia priority ervice (3GPP TS 22.153

More information

Object Oriented Programming #10

Object Oriented Programming #10 Object Oriented Programming #10 Serdar ARITAN Biomechanics Research Group, Faculty of Sports Sciences, and Department of Computer Graphics Hacettepe University, Ankara, Turkey 1 Simple programming tasks

More information

Testing Structural Properties in Textual Data: Beyond Document Grammars

Testing Structural Properties in Textual Data: Beyond Document Grammars Teting Structural Propertie in Textual Data: Beyond Document Grammar Felix Saaki and Jen Pönninghau Univerity of Bielefeld, Germany Abtract Schema language concentrate on grammatical contraint on document

More information

SIMIT 7. What's New In SIMIT V7.1? Manual

SIMIT 7. What's New In SIMIT V7.1? Manual SIMIT 7 What' New In SIMIT V7.1? Manual Edition January 2013 Siemen offer imulation oftware to plan, imulate and optimize plant and machine. The imulation- and optimization-reult are only non-binding uggetion

More information

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing

More information

An Approach to Buffer Management in Java HPC Messaging

An Approach to Buffer Management in Java HPC Messaging An Approach to Buer Management in Java HPC Meaging Mark Baker, Bryan Carpenter, and Aamir Shai Ditributed Sytem Group, Univerity o Portmouth Abtract. One o the mot challenging apect to deigning a Java

More information

Building a Compact On-line MRF Recognizer for Large Character Set using Structured Dictionary Representation and Vector Quantization Technique

Building a Compact On-line MRF Recognizer for Large Character Set using Structured Dictionary Representation and Vector Quantization Technique 202 International Conference on Frontier in Handwriting Recognition Building a Compact On-line MRF Recognizer for Large Character Set uing Structured Dictionary Repreentation and Vector Quantization Technique

More information

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism Ibrahim Albluwi Composition A GuitarString has a RingBuffer. A MarkovModel has a Symbol Table. A Symbol Table has a Binary

More information

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof Abstract Class Lecture 21 Based on Slides of Dr. Norazah Yusof 1 Abstract Class Abstract class is a class with one or more abstract methods. The abstract method Method signature without implementation

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg

More information

CSE 250B Assignment 4 Report

CSE 250B Assignment 4 Report CSE 250B Aignment 4 Report March 24, 2012 Yuncong Chen yuncong@c.ucd.edu Pengfei Chen pec008@ucd.edu Yang Liu yal060@c.ucd.edu Abtract In thi project, we implemented the recurive autoencoder (RAE) a decribed

More information

CS61A Lecture 15 Object Oriented Programming, Mutable Data Structures. Jom Magrotker UC Berkeley EECS July 12, 2012

CS61A Lecture 15 Object Oriented Programming, Mutable Data Structures. Jom Magrotker UC Berkeley EECS July 12, 2012 CS61A Lecture 15 Object Oriented Programming, Mutable Data Structures Jom Magrotker UC Berkeley EECS July 12, 2012 COMPUTER SCIENCE IN THE NEWS http://www.iospress.nl/ios_news/music to my eyes device converting

More information

CS-202 Introduction to Object Oriented Programming

CS-202 Introduction to Object Oriented Programming CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction

More information

Outline. Inheritance. Abstract Classes Interfaces. Class Extension Overriding Methods Inheritance and Constructors Polymorphism.

Outline. Inheritance. Abstract Classes Interfaces. Class Extension Overriding Methods Inheritance and Constructors Polymorphism. Outline Inheritance Class Extension Overriding Methods Inheritance and Constructors Polymorphism Abstract Classes Interfaces 1 OOP Principles Encapsulation Methods and data are combined in classes Not

More information

Routing Definition 4.1

Routing Definition 4.1 4 Routing So far, we have only looked at network without dealing with the iue of how to end information in them from one node to another The problem of ending information in a network i known a routing

More information

Structured Programming

Structured Programming CS 170 Java Programming 1 Objects and Variables A Little More History, Variables and Assignment, Objects, Classes, and Methods Structured Programming Ideas about how programs should be organized Functionally

More information

Region analysis and the polymorphic lambda calculus

Region analysis and the polymorphic lambda calculus Region analyi and the polymorphic lambda calculu Anindya Banerjee Steven Intitute of Technology ab@c.teven-tech.edu Nevin Heintze Bell Laboratorie nch@bell-lab.com Jon G. Riecke Bell Laboratorie riecke@bell-lab.com

More information

Laboratory Exercise 6

Laboratory Exercise 6 Laboratory Exercie 6 Adder, Subtractor, and Multiplier The purpoe of thi exercie i to examine arithmetic circuit that add, ubtract, and multiply number. Each circuit will be decribed in Verilog and implemented

More information

24. Inheritance. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

24. Inheritance. Java. Fall 2009 Instructor: Dr. Masoud Yaghini 24. Inheritance Java Fall 2009 Instructor: Dr. Masoud Yaghini Outline Superclasses and Subclasses Using the super Keyword Overriding Methods The Object Class References Superclasses and Subclasses Inheritance

More information

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems CSSE 120 Introduction to Software Development Exam 1 Format, Concepts, What you should be able to do, and Sample Problems Page 1 of 6 Format: The exam will have two sections: Part 1: Paper-and-Pencil o

More information

Chapter 9 - Object-Oriented Programming: Polymorphism

Chapter 9 - Object-Oriented Programming: Polymorphism Chapter 9 - Object-Oriented Programming: Polymorphism Polymorphism Program in the general Introduction Treat objects in same class hierarchy as if all superclass Abstract class Common functionality Makes

More information

Inheritance (Deitel chapter 9)

Inheritance (Deitel chapter 9) Inheritance (Deitel chapter 9) 1 2 Plan Introduction Superclasses and Subclasses protected Members Constructors and Finalizers in Subclasses Software Engineering with Inheritance 3 Introduction Inheritance

More information

Lecture 10 OOP and VB.Net

Lecture 10 OOP and VB.Net Lecture 10 OOP and VB.Net Pillars of OOP Objects and Classes Encapsulation Inheritance Polymorphism Abstraction Classes A class is a template for an object. An object will have attributes and properties.

More information

Bottom Up parsing. Bottom-up parsing. Steps in a shift-reduce parse. 1. s. 2. np. john. john. john. walks. walks.

Bottom Up parsing. Bottom-up parsing. Steps in a shift-reduce parse. 1. s. 2. np. john. john. john. walks. walks. Paring Technologie Outline Paring Technologie Outline Bottom Up paring Paring Technologie Paring Technologie Bottom-up paring Step in a hift-reduce pare top-down: try to grow a tree down from a category

More information

Performance of a Robust Filter-based Approach for Contour Detection in Wireless Sensor Networks

Performance of a Robust Filter-based Approach for Contour Detection in Wireless Sensor Networks Performance of a Robut Filter-baed Approach for Contour Detection in Wirele Senor Network Hadi Alati, William A. Armtrong, Jr., and Ai Naipuri Department of Electrical and Computer Engineering The Univerity

More information

Multiclass Road Sign Detection using Multiplicative Kernel

Multiclass Road Sign Detection using Multiplicative Kernel Proceeding of the Croatian Computer Viion Workhop, Year 1 Multicla Road Sign Detection uing Multiplicative Kernel Valentina Zadrija Mireo d. d. Zagreb, Croatia valentina.zadrija@mireo.hr Siniša Šegvić

More information

Stochastic Search and Graph Techniques for MCM Path Planning Christine D. Piatko, Christopher P. Diehl, Paul McNamee, Cheryl Resch and I-Jeng Wang

Stochastic Search and Graph Techniques for MCM Path Planning Christine D. Piatko, Christopher P. Diehl, Paul McNamee, Cheryl Resch and I-Jeng Wang Stochatic Search and Graph Technique for MCM Path Planning Chritine D. Piatko, Chritopher P. Diehl, Paul McNamee, Cheryl Rech and I-Jeng Wang The John Hopkin Univerity Applied Phyic Laboratory, Laurel,

More information

Refining SIRAP with a Dedicated Resource Ceiling for Self-Blocking

Refining SIRAP with a Dedicated Resource Ceiling for Self-Blocking Refining SIRAP with a Dedicated Reource Ceiling for Self-Blocking Mori Behnam, Thoma Nolte Mälardalen Real-Time Reearch Centre P.O. Box 883, SE-721 23 Väterå, Sweden {mori.behnam,thoma.nolte}@mdh.e ABSTRACT

More information

(12) Patent Application Publication (10) Pub. No.: US 2003/ A1

(12) Patent Application Publication (10) Pub. No.: US 2003/ A1 US 2003O196031A1 (19) United State (12) Patent Application Publication (10) Pub. No.: US 2003/0196031 A1 Chen (43) Pub. Date: Oct. 16, 2003 (54) STORAGE CONTROLLER WITH THE DISK Related U.S. Application

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