feat(cmat): add cmake build for course material
Add a CMakeLists.txt to each exercise directory, included from cmat/CMakeLists.txt, so every exercise and solution becomes a buildable target. GUI exercises link the curses-based DOS_Unix implementations on Unix-like systems; the Windows-specific DOS variants are not compiled. Exercises without a portable path or with missing dependencies (Boost) are reported as not available at configure time. Targets are excluded from the default build and built by name, e.g. `cmake --build build --target Ex11`, so intentionally buggy exercises such as Ex21 do not break the default build. Also fix two portability issues: rename Ex11bug/pole.h to Pole.h for case-sensitive filesystems and drop the extra Light:: qualification in SolutionEx71A/Light.h. Document build commands and layout in AGENTS.md. Co-authored-by: Qwen 3.8 27B <qwen3.8_27b-q3_k_xl@lmstudio.local>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
|
||||
|
||||
#include "CompanyEntry.h"
|
||||
#include "CountVisitor.h"
|
||||
#include "FindVisitor.h"
|
||||
#include "GroupEntry.h"
|
||||
#include "PersonEntry.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
|
||||
// declare an address book
|
||||
GroupEntry addressbook("My addressbook");
|
||||
|
||||
// create some entries
|
||||
PersonEntry Fred("Fred", "555 1234");
|
||||
PersonEntry Gert("Gert", "555 1235");
|
||||
PersonEntry Jim("Jim", "999 2445");
|
||||
PersonEntry Sue("Sue", "456 2951");
|
||||
PersonEntry Ingar("Ingar", "999 2345");
|
||||
PersonEntry Lisa("Lisa", "443 4532");
|
||||
CompanyEntry ShoeWorld("ShoeWorld", "Shoes", "234 4314");
|
||||
CompanyEntry BestBurgers("BestBurgers", "Food", "456 4651");
|
||||
CompanyEntry DreamPizza("DreamPizza", "Food", "935 2345");
|
||||
CompanyEntry BestBooks("BestBooks", "Books", "345 3232");
|
||||
|
||||
// add some simple entries
|
||||
addressbook.addEntry(Fred);
|
||||
addressbook.addEntry(Gert);
|
||||
addressbook.addEntry(ShoeWorld);
|
||||
|
||||
// make some groups
|
||||
GroupEntry group1("My Best Food");
|
||||
group1.addEntry(BestBurgers);
|
||||
group1.addEntry(DreamPizza);
|
||||
|
||||
GroupEntry group2("Coworkers");
|
||||
group2.addEntry(Jim);
|
||||
group2.addEntry(Sue);
|
||||
|
||||
// make a nested group
|
||||
GroupEntry group3("Favorites");
|
||||
group3.addEntry(Ingar);
|
||||
group3.addEntry(Lisa);
|
||||
group3.addEntry(BestBooks);
|
||||
group3.addEntry(group1);
|
||||
|
||||
addressbook.addEntry(group2);
|
||||
addressbook.addEntry(group3);
|
||||
|
||||
cout << "*** Print using Composite print operation\n";
|
||||
addressbook.print();
|
||||
|
||||
cout << "*** Find using Visitor\n";
|
||||
FindVisitor pv("Fred");
|
||||
addressbook.accept(pv);
|
||||
for (const Entry *p : pv.getFindings()) {
|
||||
p->print();
|
||||
}
|
||||
|
||||
// PART 2 Create a CountVisitor and let it visit the address book
|
||||
// cout << "*** Count objects using Visitor\n";
|
||||
|
||||
cout << "*** Test complete\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user