I’ve been reading up on abstract classes and interfaces, and I’m really confused.
My usual practice is to make a class, e.g.
class NPC
then
SpecificNPC extends NPC
This lets me create an array that holds NPC objects, and then stores the subclasses, so
NPC[] enemies = new NPC[10];
enemies[0] = new SpecificNPC(args)
Simple as that really, where the specific npc can override methods like attack to use different attacks, but keep movement the same. I understand an interfaces mean you have to override the methods they contain, and have no body, but how does this affect the way I have been using polymorphism ?(I think thats what i did in the enemies array?)
Also I still dont understand why you’d use a interface over abstract class, visa versa, or an abstract class over the way I have been doing it? Just wondering if anyone can help. The book I have teaches me about them, but gives me no idea of why I would ever use them.