forked from jaredtao/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (43 loc) · 1.22 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "Directory.h"
#include "File.h"
#include "ListVisitor.h"
int main()
{
Directory *root = new Directory("root");
Directory *bin = new Directory("bin");
Directory *tmp = new Directory("tmp");
Directory *usr = new Directory("usr");
root->addEntryy(bin);
root->addEntryy(tmp);
root->addEntryy(usr);
bin->addEntryy(new File("vi", 3000));
bin->addEntryy(new File("latex", 2000));
auto list1 = new ListVisitor;
root->accept(list1);
Directory *yuki = new Directory("yuki");
Directory *hanako = new Directory("hanako");
Directory *tomura = new Directory("tomura");
usr->addEntryy(yuki);
usr->addEntryy(hanako);
usr->addEntryy(tomura);
yuki->addEntryy(new File("diary.html", 100));
hanako->addEntryy(new File("memo.tex", 1024));
tomura->addEntryy(new File("junk.mail", 40));
auto list2 = new ListVisitor;
root->accept(list2);
// add for coverage
{
yuki->printList("");
Entry *e = new Directory("test");
File *f = new File("123.txt", 1024);
f->printList("");
f->addEntryy(e);
f->toString();
delete f;
delete e;
}
delete root;
delete list1;
delete list2;
return 0;
}