I didn't have any problems with the visitor pattern.. Just look at
this diagram.. the Booking is the Element (in the diagram) and Single/Double are concreteElements(in the diagram)
Just abstract the Visitor and make subclasses for each of the different rates. In each Visitor subclass you just
Language: C++ (QT)
void NonPremiumVisitor::visit(Booking* b) {
b->SINGLEBPMMM = 0.75;
b->DOUBLEBPMMM = 0.75;
}
OR
Language: C++ (QT)
void PremiumVisitor::visit(Booking* b) {
b->SINGLEBPMMM = 1.25;
b->DOUBLEBPMMM = 1.10;
}
A giveaway was that the SINGLEBPMMM and DOUBLEBPMMM were private. So we can change them in the derived classes.
and in the Booking base class (which I figured out in the exam that you only need it in the base class) you just
Language: C++ (QT)
void Booking::accept(Visitor* v) {
v->visit(this);
}