chore: Add course material
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user