JPython and subclassing from an abstract class
Pieter Laeremans
pieter at kotnet.org
Wed May 23 09:01:27 EDT 2001
Hi,
I'm a newbie to python and tried to experiment a bit with JPython.
Can anyone explain why the following doesn't work?
Consider the following java classes:
public class Rational {
public Rational(numerator, denominator){}
public long getDenominator(){}
public longgetNumerator(){}
}
public abstract class Constraint {
public abstract String getDescription();
public boolean satisifies(Rational rational);
}
I want to subclass this class in python but it doesn't work.
I've tried:
class testConstraint(Constraint):
define getDescription(self):
return "test"
define satisfies(self, rational):
return rational.getDenominator()
This didn't work!
I could crate an instance
t = testConstraint
but when i tried
r = Rational(2,1)
t.satisfies(r)
I got an error message.
Thx in advance!
Pieter
More information about the Python-list
mailing list