Suppose you are designing the file system of an operating system. The current version of the operating system supports 2 types of files – directory file and text file. A directory file contains other files while a text file contains a collection of ASCII texts. Each of the file has a name, type, create date, owner id, and permission (read and write) for owner and others. Each non directory file also has a size (in KB) attribute. Changing permission on a directory file will change the permission on that file as well as all the files stored under that directory file. Users may also query the size of a file (for a directory file, the size is the sum of size of all the files contained in the directory file and other sub directory files). A client object can have a reference to any file object and is capable of changing permission and getting size. The client object know the type of files (‘directory’ or ‘text’) but may not know how to create object of the files (apply proper creational patterns to create objects). Apply appropriate design patterns wherever application and implement an efficient file system for your operating system. Write a test program to create the file hierarchy and test your client program. Now, add a new file type (called multimedia file) to your file system without changing the existing code except adding its type ‘multimedia’.
Aucun commentaire:
Enregistrer un commentaire