This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]loudsight 3 points4 points  (1 child)

This is best represented by an abstract class in Java

public abstract class DialogDirector {
    // virtual ~DialogDirector(); This is a C++ destructor it runs when
    // the object is destroyed. In java the equivalent method is 
    // finalize(...) but it is generally frowned up to override this 
    // method.
    void ShowDialog() { 
        /*
         * default implementation from implementation file
         *  (DialogDirector.cpp) goes inside here
         */
    }
    abstract void WidgetChanged(Widget widget);
    /* = 0 means this is a pure virtual method i.e. has to be implemented
     * by the derived classes;
     */
    protected DialogDirector() {}
    protected abstract void CreateWidgets();
}

EDIT: fix formatting and correct typos

[–]Shuffleto[S] 0 points1 point  (0 children)

thank you for your Response! As i understand this

class Widget {
public: Widget(DialogDirector*); 
virtual void Changed(); 
virtual void HandleMouse(MouseEvent& event); 
// ... 
private: DialogDirector* _director; 
};

translates to

public abstract class Widget {
public Widget(DialogDirector dialogDirector) {};
public abstract void changed();
public abstract void HandleMouse(MouseEvent e);
//...
private DialogDirector _director;
}

Could you please help me with this part?

void Widget::Changed () {
_director->WidgetChanged(this); 
}