I’m writing code for a game currently in java (newbie programmer here), but I’m unsure of the dangers or benefits or if i should, of having the abstract class that initializes a displaymode and enters game loop THAT implements a key listener for controls
Share
Abstract Classis betweenInterfaceand andBaseClassi.e. it may have some implemented methods and some unimplemented methods.All methods of sub classes which have common implementation can be implemented in Abstract class itself.
If you think your
Listenerimplementation is common across most of the implementing implementing classes of the abstract class, then I think it’s completely fine to define the listener in the abstract class. If implementation is not same but the same method is required in most of the implementing classes, then define the signature as an abstract method in the abstract class. If nothing is common, then I think you had better not have it in the abstract class.