-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectory.java
131 lines (121 loc) · 3.29 KB
/
Directory.java
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import java.util.ArrayList;
/**
* An object of the class Directory represents a directory of the filesystem.
*
* @author TGNU Team
* @version 1.0
*/
public class Directory
{
private String name;
private String password;
private ArrayList<Directory> childs;
private ArrayList<File> files;
private Directory parent;
/**
* The constructor creates an object of the class Directory.
* It requires a String name and a String password.
*
* @param String name The name of the directory.
* @param String password The password which is required to access this directory.
* @param Directory parent The directories parent.
*/
public Directory(String name, String password, Directory parent)
{
this.name = name;
this.password = password;
this.parent = parent;
childs = new ArrayList<Directory>();
files = new ArrayList<File>();
}
/**
* The constructor creates an object of the class Directory.
* It requires a String name and a String password.
*
* @param String name The name of the directory.
* @param String password The password which is required to access this directory.
*/
public Directory(String name, Directory parent)
{
this.name = name;
this.password = password;
childs = new ArrayList<Directory>();
this.parent = parent;
files = new ArrayList<File>();
}
/**
* The constructor creates an object of the class Directory.
* It requires a String name.
*
* @param String name The name of the directory.
*/
public Directory(String name)
{
this.name = name;
childs = new ArrayList<Directory>();
files = new ArrayList<File>();
}
/**
* get the ArrayList<Directory> childs
*
* @return return the ArrayList<Directory> childs
*/
public ArrayList<Directory> getChilds()
{
return childs;
}
/**
* Get the ArrayList<File> files
*
* @return return the ArrayList<File> files
*/
public ArrayList<File> getFiles()
{
return files;
}
/**
* Get the parent of this directory
*
* @return Directory parent The parent directory
*/
public Directory getParent()
{
return parent;
}
/**
* Get the name of this directory
*
* @return String name The name of the directory.
*/
public String getName()
{
return name;
}
/**
* Get the password of this directory
*
* @return String password The password of this directory
*/
public String getPassword()
{
return password;
}
/**
* Add a Directory object to the ArrayList childs
*
* @param Directory child The instance of the class Directory which needs to be added to the ArrayList childs
*/
public void addChild(Directory child)
{
childs.add(child);
}
/**
* Add a File object to the ArrayList files
*
* @param File file The instance of the class File which needs to be added to the ArrayList files
*/
public void addFile(File file)
{
files.add(file);
}
}