lecture-13

lecture-13 - Recap Inheritance class Shape def draw(self...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Recap: Inheritance class Shape: def draw(self, screen): # some python code here def erase(self, screen): screen.setcolor(“white”) self.draw(screen) screen.setcolor(“black”) class Rec(Shape): def draw(self, screen): # some python code here class Oval(Shape): def draw(self, screen): # some python code here Recap: Complex numbers class Real: RealPart = 0 class Complex: RealPart = 0 ComplexPart = 0 The same exact options present themselves here, with the same tradeoffs! Summary of (single) inheritance • Inheritance is a powerful mechanism • From the programmer’s perspective, difficulty is in defining the inheritance diagram • From a language implementer’s perspective, difficulty is in making dynamic dispatch work Multiple inheritance class ColorTextBox(ColorBox,TextPoint): def draw(self,screen,pos): ColorBox.draw(self,screen,pos) r=TextPoint.draw(self,screen,pos) return r def __str__(self): return ColorBox.__str__(self) + " text: " + str(self.text) What are the issues? • Inheritance tree becomes a DAG
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/08/2011 for the course CSE cse130 taught by Professor Cs during the Fall '10 term at UCSD.

Page1 / 3

lecture-13 - Recap Inheritance class Shape def draw(self...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online