Files and Directories Exercise

This is work to be done via pair programming.

Part Two

Take the code you wrote for Part One and modify it further. Make the files/directories structure follow the composite design pattern.

If you did not make your factories Singletons in Part One, make sure they are in Part Two.

Submit the resulting code the same way you did Part One (make a new link so I can see both parts).

Part One

Code to modify

Do this assignment with pair programming. When your team is done, each person should put the code on your individual assignment link page. Make the link read "Files and Directories exercise".

Start with the Java code above. It creates a file system tree containing files, and directories (which themselves contain files and directories). The main makes some files and some directories and glues them all together.

Modify it to make each object created by an appropriate factory.

Also modify it to allow two types of files. Right now there is one file type. When it is shown in the output, its name is displayed. Create a second type of file that has no display name. Rather it is identified by a number, and when it is "displayed" it will mean to send it to a rendering device like an audio card. You can mimick this display in the code by simply printing something like the file number and a message like "rendering".

We want the main to still "display" all the elements in the file tree. Create some of the second file types and add them into the tree. Print out parts of the structure.