Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
Like this article? We recommend

PathWidget Class Implementation

Listing 9 illustrates the implementation in all its glory! Notice that the constructor calls the base class constructor, which shows the magic of object orientation! The base class object then maintains the pointer to the mediator, which reduces the level of clutter in the subclasses. The CreateInitialPath() method is used to create an initial configuration for the PathWidget instance. To retrieve the configuration, we use the getNewPath() method. To change the configuration, we use the ChangePath() method.

Listing 9 PathWidget Implementation Code

PathWidget::PathWidget(ConnectionDirector* theDirector) : Widget(theDirector)
{
}

PathWidget::~PathWidget(void)
{
}

void PathWidget::CreateInitialPath(char* newPath)
{
  pathDetails = newPath;
  printf("Initial path setting: %s\n", pathDetails);
}

void PathWidget::getNewPath(void)
{
  printf("The PathWidget path is: %s\n", pathDetails);
}

void PathWidget::ChangePath(char* newPath)
{
  pathDetails = newPath;
  printf("The updated PathWidget path is: %s\n", pathDetails);
  Changed();
}

The semantics for the other widget subclass are almost identical, so I won’t list them here. Let’s now see how all this code works when we run the program.

  • + Share This
  • 🔖 Save To Your Account