The essential properties of a Thing are as follows :
- The constructor should take in 1 parameter, the name of the Thing.
stone = Thing ('stone ')
- owner : an attribute that stores the owner object of the Thing, usually a Person object.
In OOP, we set this attribute to None during initialization when this Thing does not belong to any Person yet (to signify the absence of an object value).
stone . owner
None
- is_owned(): returns a boolean value, True if the thing is “owned” and False otherwise.
stone . is_owned ()
False
4.get_owner(): returns the Person object who owns the Thing object.
stone . get_owner ()
None
Implement the class Thing such that it satisfies the above properties and methods.
im not sure what is wrong with my code:
class Thing:
def __init__(self,name):
self.name=name
self.owner=None
def is_owned(self):
return self.owner!=None
def get_owner(self):
return self.owner
My question: as the question states, when i input stone.owner, i expect to receive an output None. however, there is no output at all. edit: no output received is accepted instead of None. However, is there any way to return None from stone.owner?
is_ownedbut you have in your codeis_owner. Tell please what exactly is wrong, what output you are getting, and what output you would like to get.