{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw7 - Suggested Homework#8 Suggested Homework#7(for Quiz#7...

This preview shows pages 1–3. Sign up to view the full content.

Suggested Homework #8 Suggested Homework #7 (for Quiz #7 on 11/16/06) Consider the Python code below: class Count: ctr = 0 def __init__(self,init,fnext): self.ctr = init self.n = fnext def nextValue(self): return self.n(self.ctr) def next(self): self.ctr = self.nextValue() return self.ctr class DCount(Count): def nextValue(self): return self.n(self.n(self.ctr)) c = Count(1,lambda x: x + 1) d = DCount(1,lambda x: 2*x) c.next() d.next() f = d.next r1 = DCount.ctr r2 = c.ctr r3 = d.ctr r4 = f() r5 = Count.next(d) def accelerate(C,n): class aC(C): def next(self): for i in range(n): C.next(self) return self.ctr return aC E = accelerate(Count,5) e = E(0,lambda x: x + 1) r6 = e.nextValue() r7 = e.next() (a) What are the attributes of the namespace Count ? http://www.cs.ucsd.edu/classes/fa06/cse130/shw/shw7.html (1 of 3) [2/13/2008 5:26:13 PM]

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

View Full Document
Suggested Homework #8 (b) What are the attributes of the namespace DCount ? (c) Which class is the super class, which class is the subclass ? (d) Which methods does the subclass inherit from the superclass ?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

hw7 - Suggested Homework#8 Suggested Homework#7(for Quiz#7...

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

View Full Document
Ask a homework question - tutors are online