WEEK 7 ASSIGNMENT – PART 1 Directory hierarchy

Original price was: $35.00.Current price is: $29.00.

Rate this product

You have been provided with a file that implements a data structure for representing the
directory hierarchy of a file system in a computer. The file includes an interface FSObject and three
classes that implement the interface and contain a constructor and getters. These three classes are:
 A class File which has two fields: a name and the size of the file
 A class Directory which has two fields: a name and a list of the file system objects the directory
 A class Link which has two fields: a name and the path to the file or directory that it links to
The code also contains test code in the main function that is expected to work for a correct solution. Do
not modify this test code.
1. In main, create a value myFS of type FSObject that stores a file system object with the
following hierarchy:
+—- dirB
| +—- dirC
| | +—- file1 (4096 B)
| | +—- file2 (2097152 B)
| | +—- linkX -> dirA/dirD/file4
| +—- linkY -> dirA/dirD/file4
+—- dirD
+—- file3 (4194304 B)
+—- file4 (128 B)
+—- linkZ -> dirA/dirB/dirC/file1
2. Add an instance method totalSize that returns the total size of all the files in the hierarchy.
3. Create a visitor FSObjectVisitor that visits FSObject and its subtypes. You may modify
FSObject and its subtypes to accept FSObjectVisitor.
4. Use FSObjectVisitor to define a custom visitor called PrintLargeFilesVisitor that
prints the names of all the files larger than 1 MiB (1048576 B).
Solutions should be:
 Correct
 In good style, including indentation and line breaks
 Written using features discussed in class
Submission Instructions
Submit your file via Moodle. Do not submit any other files or compressed folders.


There are no reviews yet.

Be the first to review “WEEK 7 ASSIGNMENT – PART 1 Directory hierarchy”

Your email address will not be published. Required fields are marked *

Scroll to Top