-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
26 lines (21 loc) · 852 Bytes
/
Main.java
File metadata and controls
26 lines (21 loc) · 852 Bytes
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
public class Main {
public static void main(String[] args) {
// Create files
Component file1 = new Leaf("file1.txt", 100);
Component file2 = new Leaf("file2.txt", 50);
// Create subdirectory
Composite subDirectory = new Composite("Subdirectory");
Component file3 = new Leaf("file3.txt", 75);
subDirectory.addComponent(file3);
// Create root directory
Composite rootDirectory = new Composite("Root");
rootDirectory.addComponent(file1);
rootDirectory.addComponent(file2);
rootDirectory.addComponent(subDirectory);
// Display file system information
rootDirectory.displayInfo();
// Calculate total size
int totalSize = rootDirectory.getSize();
System.out.println("Total size: " + totalSize + " bytes");
}
}