chore: Add course material
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#pragma warning(disable : 4786)
|
||||
// GroupEntry.cpp
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "EntryVisitor.h"
|
||||
#include "GroupEntry.h"
|
||||
#include "PersonEntry.h"
|
||||
|
||||
GroupEntry::GroupEntry(std::string name) : Entry(name) {}
|
||||
|
||||
void GroupEntry::print(std::string indent) const {
|
||||
// print group name
|
||||
std::cout << indent << "Group: " << getName() << '\n';
|
||||
|
||||
// Part 1: call print() on each group member (with increased indent level)
|
||||
|
||||
for (auto p : _entries) {
|
||||
p->print(indent + " ");
|
||||
}
|
||||
}
|
||||
|
||||
void GroupEntry::addEntry(const Entry &entry) {
|
||||
// Part 1: Add the entry to this group
|
||||
|
||||
_entries.push_back(&entry);
|
||||
}
|
||||
|
||||
void GroupEntry::accept(EntryVisitor &v) const {
|
||||
v.visit(*this);
|
||||
|
||||
// pass visitor to my children
|
||||
for (auto p : _entries) {
|
||||
p->accept(v);
|
||||
}
|
||||
|
||||
v.unVisit(*this);
|
||||
}
|
||||
Reference in New Issue
Block a user