they're making me do traitsinterface IWindow {
bool maximise() unimplemented;
std::string getWindowName() { return windowName; }
bool setWindowName(std::string newName) unimplemented;
// Private in this system is the equivalent of `protected` in C++
private:
// I would imagine this would be beneficial? But I know that Rust doesn't allow this...
std::string windowName;
}
class SDLWindow implements IWindow {
constructor(std::string winName, Vector2i size, int flags) {
win = SDL_CreateWindow(winName.c_str(), size.x, size.y, flags);
windowName = winName;
}
destructor() {
SDL_DestroyWindow(win);
}
bool maximise() {
return SDL_MaximiseWindow(win);
}
bool setWindowName(std::string newName) {
bool success = SDL_SetWindowName(newName);
if (success)
windowName = newName;
return success;
}
private:
SDL_Window* win;
};
// Error in trait style: can't extend classes, only interfaces
class SDLWindowWithRenderer implements SDLWindow {};
// Presume IPrintable is provided by your code but SDLWindow is an external dep in this scenario
implement IPrintable for SDLWindow {
std::string toString() { ... }
};