forked from jaredtao/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (45 loc) · 1.25 KB
/
main.cpp
File metadata and controls
51 lines (45 loc) · 1.25 KB
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
48
49
50
51
#include "Directory.h"
#include "File.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));
static_cast<Entry *>(root)->printList();
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));
static_cast<Entry *>(root)->printList();
// for test coverage
{
File *f = new File("123.txt", 1);
f->addEntryy(root);
f->printList("");
delete f;
}
{
yuki->printList("");
}
{
File *f = new File("123.txt", 1);
Entry *e = new Directory("test");
e->addEntryy(f);
e->printList("");
e->toString();
delete e;
}
delete root;
return 0;
}