I have a parent class MediaWindow which is extended by multiple child classes VideoWindow, PictureWindow etc.
Each subclass of classes must implement two particular functions which relate to resizing.
My thought was for the parent class to implement an interface e.g. IResizableWindow.
Since every MediaWindow must provide an implementation of the resizing function I thought it makes sense that MediaWindow implements IResizableWindow directly. However since the subclasses each need to have different implementations of the resizing functions, the functions cannot be directly implemented on the parent class.
public interface IResizableWindow {
function resizeContent():void;
function getResizeDimensions():Rectangle;
}
public class MediaWindow implements IResizableWindow {
...
}
public class ImageWindow extends MediaWindow {
...
public function resizeContent():void {
// function implementation
}
public function getResizeDimensions():Rectangle {
// function implementation
}
...
}
However this will throw the error Interface method resizeContent in namespace IResizableWindow not implemented by class MediaWindow. & same for the getResizeDimensions() function.
Is the best solution for each of the subclasses to individually implement the IResizableWindow interface?
e.g.
public class ImageWindow extends MediaWindow implements IResizableWindow {
...
}
It feels annoying to have to explicitly state that every single child class implements the interface individually when I want it to be the case for all subclasses of MediaWindow but perhaps this is the only way.
Thanks for your advice in advance.
MediaWindow"abstract", these must not be initialized but instances of subclasses could exist, be created but those subclasses must implement all the interface methods. (But IIRC there's no abstract class in AS3, outatime to verify)MediaWindowwhich throw an error if not overridden. I'd rather a neater way of doing it but seeing as I don't want every subclass to have to individually implement the interface it'll have to do.