Skip to content
Advertisement

Tag: interface

Attributes / member variables in interfaces?

I wish to know is there any way in which I can make it compulsory for the implementer class to declare the objects handles/primitives as they do with methods. for e.g.: In the above method how can we compel Tile class to declare height and width attributes using the interface? For some reason I wish to do it with interface

The purpose of interfaces continued

OK so I gather that Interfaces are a way to enforce that an object implements a certain amount of functionality, without having to use inheritance. Kind of like a contract. And I semi see the point of them. But if all you have in the interface is: and it has no implementation as such, then whoever uses your interface has

Advertisement