Files
2026-10-05 11:27:21 +02:00

25 lines
740 B
C++

#include "PrintVisitor.h"
#include "CompanyEntry.h"
#include "GroupEntry.h"
#include "PersonEntry.h"
#include <iostream>
void PrintVisitor::visit(const PersonEntry &pe) {
std::cout << indent << "Person: " << pe.getName() << ' ' << pe.getPhone() << '\n';
}
void PrintVisitor::visit(const CompanyEntry &ce) {
std::cout << indent << "Company: " << ce.getName() << " <" << ce.getCategory() << "> " << ce.getPhone() << '\n';
}
void PrintVisitor::visit(const GroupEntry &ge) {
std::cout << indent << "Group: " << ge.getName() << '\n';
indent += " ";
}
void PrintVisitor::unVisit(const GroupEntry &) {
// Get rid of the extra indent we added
indent = indent.substr(indent.length() - 2, 2);
}