Code: Select all
class What:
def __init__(self, v):
self.x = v;
def get(self):
return self.x
def set(self, v):
self.x = v;
[Note that the "self" as the first parameter of each method is required, and that the
__init__(self, v):
is the constructor for this class.]
"Save" this and then in the Jython shell, you can do the following to check it out. Note that "z" and "m" are different instances of the class "What"....the possibilities are endless....
z=What(13)
print z.get()
13
z.set(99)
print z.get()
99
m = What(15)
print m.get()
15
print z.get()
99